[llvm-bugs] [Bug 37309] New: Missed optimizations when ANDing comparisons

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 2 04:02:41 PDT 2018


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

            Bug ID: 37309
           Summary: Missed optimizations when ANDing comparisons
           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

Hello,

Code:

int foo(long a, long b, long c) {
  int h1 = a > b;
  int h2 = a > c;
  return h1 & h2;
}

Clang with -O3 generates: 

foo:
  cmp rdi, rsi
  setg al
  cmp rdi, rdx
  setg cl
  and cl, al
  movzx eax, cl
  ret

But maybe a better code can be generated? Like:

foo:
  cmp rsi, rdx
  cmovl rsi, rdx
  xor eax, eax
  cmp rdi, rsi
  setg al
  ret

-- 
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/20180502/1465a08c/attachment.html>


More information about the llvm-bugs mailing list