[llvm-bugs] [Bug 47279] New: Missed elimination of comparison with zero

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 21 16:42:24 PDT 2020


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

            Bug ID: 47279
           Summary: Missed elimination of comparison with zero
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

extern void foo (void);

void
bar (int z, unsigned int y)
{
  long long x = z;
  y &= 0xf;
  if (x >= 0 && x < (int) y)
    foo ();
}

Clang -O3:
bar:                                    # @bar
        test    edi, edi
        js      .LBB0_2
        and     esi, 15
        cmp     esi, edi
        jbe     .LBB0_2
        jmp     foo                             # TAILCALL
.LBB0_2:
        ret

GCC -O3:
bar:
        and     esi, 15
        cmp     edi, esi
        jb      .L4
        ret
.L4:
        jmp     foo

-- 
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/20200821/98cf965d/attachment.html>


More information about the llvm-bugs mailing list