[llvm-bugs] [Bug 51080] New: branch not eliminated

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 13 10:06:11 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51080

            Bug ID: 51080
           Summary: branch not eliminated
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: jmuizelaar at mozilla.com
                CC: llvm-bugs at lists.llvm.org

void kill (void);

 void foo (unsigned int arg)
 {
   int a = arg - 3;
   unsigned int b = 4;
   int x = 0x1 << arg;

   if (a < 0)
     b = x;

   if (b >=  5)
     kill ();;
 }

produces:

foo(unsigned int):                                # @foo(unsigned int)
        cmp     edi, 3
        jb      .LBB0_2
        add     edi, -3
        jns     .LBB0_2
        jmp     kill()                        # TAILCALL
.LBB0_2:
        ret

with clang trunk: -O2 -mllvm -enable-constraint-elimination

gcc trunk -O2 gives:

foo(unsigned int):
        ret

test case from:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93781

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210713/4c69fcdf/attachment.html>


More information about the llvm-bugs mailing list