[llvm-bugs] [Bug 48643] New: Missed opportunity for value range propagation from binary ops

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 1 01:40:05 PST 2021


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

            Bug ID: 48643
           Summary: Missed opportunity for value range propagation from
                    binary ops
           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
foo (unsigned int x, unsigned int y)
{
  unsigned int min;
  if (x >= 3 && x <= 6)
    return;
  if (y >= 5 && y <= 8)
    return;
  min = x < y ? x : y;
  if (min == 5)
    foo ();
  if (min == 6)
    foo ();
}


LLVM (even with experimental CE pass)
foo(unsigned int, unsigned int): # @foo(unsigned int, unsigned int)
  lea eax, [rdi - 3]
  cmp eax, 4
  jb .LBB0_4
  lea eax, [rsi - 5]
  cmp eax, 4
  jb .LBB0_4
  cmp edi, esi
  cmovb esi, edi
  cmp esi, 6
  je .LBB0_5
  cmp esi, 5
  jne .LBB0_4
.LBB0_5:
  jmp foo() # TAILCALL
.LBB0_4:
  ret


GCC:
foo(unsigned int, unsigned int):
        ret


https://godbolt.org/z/sMc4s7

-- 
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/20210101/792b31c6/attachment.html>


More information about the llvm-bugs mailing list