[Bug tree-optimization/105832] [13 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 12.1.0)

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 14 11:50:51 GMT 2022


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).


More information about the Gcc-bugs mailing list