Skip to content

Commit bd07e87

Browse files
committed
[NFC] Pre commit test for fold trunc nsw X to i1 -> true IFF X != 0
1 parent 2b129da commit bd07e87

File tree

1 file changed

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

1 file changed

+35
-0
lines changed

llvm/test/Transforms/InstCombine/trunc.ll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,3 +1172,38 @@ define i1 @neg_trunc_i1_non_zero(i8 %1) {
11721172
%ret = trunc i8 %1 to i1
11731173
ret i1 %ret
11741174
}
1175+
1176+
define i1 @trunc_nsw_i1_non_zero(i8 %1) {
1177+
; CHECK-LABEL: @trunc_nsw_i1_non_zero(
1178+
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
1179+
; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
1180+
; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0]] to i1
1181+
; CHECK-NEXT: ret i1 [[RET]]
1182+
;
1183+
%3 = icmp ne i8 %1, 0
1184+
tail call void @llvm.assume(i1 %3)
1185+
%ret = trunc nsw i8 %1 to i1
1186+
ret i1 %ret
1187+
}
1188+
1189+
define i1 @neg_trunc_nsw_i1_maybe_zero(i8 %1) {
1190+
; CHECK-LABEL: @neg_trunc_nsw_i1_maybe_zero(
1191+
; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0:%.*]] to i1
1192+
; CHECK-NEXT: ret i1 [[RET]]
1193+
;
1194+
%ret = trunc nsw i8 %1 to i1
1195+
ret i1 %ret
1196+
}
1197+
1198+
define i2 @neg_trunc_nsw_i2_non_zero(i8 %1) {
1199+
; CHECK-LABEL: @neg_trunc_nsw_i2_non_zero(
1200+
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
1201+
; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
1202+
; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0]] to i2
1203+
; CHECK-NEXT: ret i2 [[RET]]
1204+
;
1205+
%3 = icmp ne i8 %1, 0
1206+
tail call void @llvm.assume(i1 %3)
1207+
%ret = trunc nsw i8 %1 to i2
1208+
ret i2 %ret
1209+
}

0 commit comments

Comments
 (0)