[NFC][InstCombine] Add shift amount reassociation in bittest miscompile example from...
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 14:14:43 +0000 (17:14 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 15:23:58 +0000 (18:23 +0300)
https://bugs.llvm.org/show_bug.cgi?id=44802

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

index 2722470..0386d80 100644 (file)
@@ -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
+}