[llvm-branch-commits] [llvm] ac293ed - [NFC][InstCombine] Add shift amount reassociation in bittest miscompile example from PR44802

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 27 04:58:55 PST 2020


Author: Roman Lebedev
Date: 2020-02-27T13:45:21+01:00
New Revision: ac293ede5e62cfc569f2d5d8f4667e6188afced0

URL: https://github.com/llvm/llvm-project/commit/ac293ede5e62cfc569f2d5d8f4667e6188afced0
DIFF: https://github.com/llvm/llvm-project/commit/ac293ede5e62cfc569f2d5d8f4667e6188afced0.diff

LOG: [NFC][InstCombine] Add shift amount reassociation in bittest miscompile example from PR44802

https://bugs.llvm.org/show_bug.cgi?id=44802
(cherry picked from commit 6f807ca00d951d3e74f7ea4fe1daa8e3560f4c0d)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
index 27224705929c..0386d8042f92 100644
--- a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
+++ b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
@@ -687,3 +687,20 @@ entry:
   %tobool = icmp ne i16 %and, 0
   ret i1 %tobool
 }
+
+; FIXME: this is a miscompile. We should not transform this.
+; See https://bugs.llvm.org/show_bug.cgi?id=44802
+define i1 @pr44802(i3 %a, i3 %x, i3 %y) {
+; CHECK-LABEL: @pr44802(
+; CHECK-NEXT:    [[TMP1:%.*]] = and i3 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i3 [[TMP1]], 0
+; CHECK-NEXT:    ret i1 [[TMP2]]
+;
+  %t0 = icmp ne i3 %a, 0
+  %t1 = zext i1 %t0 to i3
+  %t2 = lshr i3 %x, %t1
+  %t3 = shl i3 %y, %t1
+  %t4 = and i3 %t2, %t3
+  %t5 = icmp ne i3 %t4, 0
+  ret i1 %t5
+}


        


More information about the llvm-branch-commits mailing list