Skip to content

Commit a1652fd

Browse files
committed
[InstCombine] Add tests for incorrect shift nneg inference (NFC)
The second test is a miscompile.
1 parent 6088e9c commit a1652fd

File tree

1 file changed

+22
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+22
-0
lines changed

llvm/test/Transforms/InstCombine/shift.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,4 +2195,26 @@ define i16 @ashr_umax_demanded(i16 %x) {
21952195
ret i16 %shr
21962196
}
21972197

2198+
define i128 @shift_zext_nneg(i8 %arg) {
2199+
; CHECK-LABEL: @shift_zext_nneg(
2200+
; CHECK-NEXT: [[EXT:%.*]] = zext nneg i8 [[ARG:%.*]] to i128
2201+
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i128 1, [[EXT]]
2202+
; CHECK-NEXT: ret i128 [[SHL]]
2203+
;
2204+
%ext = zext i8 %arg to i128
2205+
%shl = shl i128 1, %ext
2206+
ret i128 %shl
2207+
}
2208+
2209+
define i129 @shift_zext_not_nneg(i8 %arg) {
2210+
; CHECK-LABEL: @shift_zext_not_nneg(
2211+
; CHECK-NEXT: [[EXT:%.*]] = zext nneg i8 [[ARG:%.*]] to i129
2212+
; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i129 1, [[EXT]]
2213+
; CHECK-NEXT: ret i129 [[SHL]]
2214+
;
2215+
%ext = zext i8 %arg to i129
2216+
%shl = shl i129 1, %ext
2217+
ret i129 %shl
2218+
}
2219+
21982220
declare i16 @llvm.umax.i16(i16, i16)

0 commit comments

Comments
 (0)