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

            Bug ID: 37750
           Summary: Missed range based optimizations
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Hello,

int g2(unsigned a, unsigned b) {
  if (a > 0 && b > 0) 
    return b + a != 0;
    // return b == 0;
    // return a + b > 0;

  return -1;
}


Long/suboptimal code for cases above ^ - clang/llvm trunk:
g2(unsigned int, unsigned int): # @g2(unsigned int, unsigned int)
  xor ecx, ecx
  mov eax, esi
  add eax, edi
  setne cl
  cmp esi, 1
  sbb edx, edx
  cmp edi, 1
  sbb eax, eax
  or eax, edx
  or eax, ecx
  ret


GCC:
g2(unsigned int, unsigned int):
  test edi, edi
  je .L3
  test esi, esi
  je .L3
  xor eax, eax
  add edi, esi
  setne al
  ret
.L3:
  mov eax, -1
  ret

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to