[llvm-bugs] [Bug 28238] New: [InstCombine] icmp slt 0 optimization hinders more optimization

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 21 08:09:32 PDT 2016


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

            Bug ID: 28238
           Summary: [InstCombine] icmp slt 0 optimization hinders more
                    optimization
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Spinning this off from bug 27869 (and may have a different solution than bug
28221):

int f(int i) {
  return (i == 0) & (i >> 31);
}

'i' can't be 0 and have a bit set, so this should return 0.

$ ./clang -O1 sneaky_icmp.c -S -o - -emit-llvm
...
define i32 @f(i32 %i) {
  %cmp = icmp eq i32 %i, 0
  %conv = zext i1 %cmp to i32
  %shr = ashr i32 %i, 31
  %and = and i32 %conv, %shr
  ret i32 %and
}

-- 
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/20160621/fcec8f0e/attachment.html>


More information about the llvm-bugs mailing list