Skip to content

Commit 6f807ca

Browse files
committed
[NFC][InstCombine] Add shift amount reassociation in bittest miscompile example from PR44802
https://bugs.llvm.org/show_bug.cgi?id=44802
1 parent 781d077 commit 6f807ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,20 @@ entry:
687687
%tobool = icmp ne i16 %and, 0
688688
ret i1 %tobool
689689
}
690+
691+
; FIXME: this is a miscompile. We should not transform this.
692+
; See https://bugs.llvm.org/show_bug.cgi?id=44802
693+
define i1 @pr44802(i3 %a, i3 %x, i3 %y) {
694+
; CHECK-LABEL: @pr44802(
695+
; CHECK-NEXT: [[TMP1:%.*]] = and i3 [[X:%.*]], [[Y:%.*]]
696+
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i3 [[TMP1]], 0
697+
; CHECK-NEXT: ret i1 [[TMP2]]
698+
;
699+
%t0 = icmp ne i3 %a, 0
700+
%t1 = zext i1 %t0 to i3
701+
%t2 = lshr i3 %x, %t1
702+
%t3 = shl i3 %y, %t1
703+
%t4 = and i3 %t2, %t3
704+
%t5 = icmp ne i3 %t4, 0
705+
ret i1 %t5
706+
}

0 commit comments

Comments
 (0)