Add a complex missed optimization opportunity I came across while investigating
authorNick Lewycky <nicholas@mxc.ca>
Sun, 15 Nov 2009 17:51:23 +0000 (17:51 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sun, 15 Nov 2009 17:51:23 +0000 (17:51 +0000)
bug 5438.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88855 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/README.txt

index bcc55b41e1a55fd10f25c4724c1e418b0a514164..aad621f440ac7c3f424b371eacbbf39539ac01b5 100644 (file)
@@ -1719,3 +1719,18 @@ static int foo(const char *X) { return strlen(X); }
 int bar() { return foo("abcd"); }
 
 //===---------------------------------------------------------------------===//
+
+InstCombine should use SimplifyDemandedBits to remove the or instruction:
+
+define i1 @test(i8 %x, i8 %y) {
+  %A = or i8 %x, 1
+  %B = icmp ugt i8 %A, 3
+  ret i1 %B
+}
+
+Currently instcombine calls SimplifyDemandedBits with either all bits or just
+the sign bit, if the comparison is obviously a sign test. In this case, we only
+need all but the bottom two bits from %A, and if we gave that mask to SDB it
+would delete the or instruction for us.
+
+//===---------------------------------------------------------------------===//