[llvm-bugs] [Bug 42207] New: Missing simplification (x > y) AND (x > z) to x > MAX (y, z))

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 9 07:28:37 PDT 2019


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

            Bug ID: 42207
           Summary: Missing simplification (x > y) AND (x > z) to x > MAX
                    (y,z))
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

unsigned int max (unsigned int i, unsigned int m, unsigned int n) {
    return i > m && i > n;
}

unsigned int max2 (unsigned int i, unsigned int m, unsigned int n) {
    return i > std::max (m,n);
}

Clang -O3
max(unsigned int, unsigned int, unsigned int):
  cmp edi, esi
  seta al
  cmp edi, edx
  seta cl
  and cl, al
  movzx eax, cl
  ret
max2(unsigned int, unsigned int, unsigned int):  int, unsigned int)
  cmp esi, edx
  cmovb esi, edx
  xor eax, eax
  cmp esi, edi
  setb al
  ret

GCC generates same code for both functions.

-- 
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/20190609/3826cb84/attachment.html>


More information about the llvm-bugs mailing list