https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105832

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot 
gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the difference boils down to GCC 12 ending up with

if (iftmp.0_9 == 1)
 {
   if (iftmp.1_10 != 0)
     {
       loop with call to foo ();
     }
 }

while the new unswitching code swaps these and ends up with

if (iftmp.1_10 != 0)
 {
   if (iftmp.0_9 == 1)
     {
       loop with call to foo ();
     }
 }

the old code also created one pointless unreachable loop copy.  GCC 12
manages to elide the loop calling foo() in thread2 after fre5.

There's nothing wrong with unswitching here I think - we're at most unlucky
with the order of unswitchings (but that might change from current 'random'
to a cost based order).

Reply via email to