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

            Bug ID: 104639
           Summary: Useless loop not fully optimized anymore
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.campredon at gmail dot com
  Target Milestone: ---

the following code compiled with -02
-------------------
bool foo(int i) {
    while (i == 4)
        i += 2;
    return i;
}
------------------

Trunk generates the following assembly
---------
foo(int):
        cmp     edi, 4
        mov     eax, 6
        cmove   edi, eax
        test    edi, edi
        setne   al
        ret
---------

whereas 11.2 generate more optimized assembly

---------
foo(int):
        test    edi, edi
        setne   al
        ret
--------

Reply via email to