[llvm] bd07e87 - [NFC] Pre commit test for fold trunc nsw X to i1 -> true IFF X != 0
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 8 13:05:00 PST 2024
Author: Andreas Jonson
Date: 2024-12-08T22:04:52+01:00
New Revision: bd07e87082aec965820b1facc495a1363cbc243f
URL: https://github.com/llvm/llvm-project/commit/bd07e87082aec965820b1facc495a1363cbc243f
DIFF: https://github.com/llvm/llvm-project/commit/bd07e87082aec965820b1facc495a1363cbc243f.diff
LOG: [NFC] Pre commit test for fold trunc nsw X to i1 -> true IFF X != 0
Added:
Modified:
llvm/test/Transforms/InstCombine/trunc.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/trunc.ll b/llvm/test/Transforms/InstCombine/trunc.ll
index f29ecb8c313738..fda99dd5ac3e3b 100644
--- a/llvm/test/Transforms/InstCombine/trunc.ll
+++ b/llvm/test/Transforms/InstCombine/trunc.ll
@@ -1172,3 +1172,38 @@ define i1 @neg_trunc_i1_non_zero(i8 %1) {
%ret = trunc i8 %1 to i1
ret i1 %ret
}
+
+define i1 @trunc_nsw_i1_non_zero(i8 %1) {
+; CHECK-LABEL: @trunc_nsw_i1_non_zero(
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
+; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
+; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0]] to i1
+; CHECK-NEXT: ret i1 [[RET]]
+;
+ %3 = icmp ne i8 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %ret = trunc nsw i8 %1 to i1
+ ret i1 %ret
+}
+
+define i1 @neg_trunc_nsw_i1_maybe_zero(i8 %1) {
+; CHECK-LABEL: @neg_trunc_nsw_i1_maybe_zero(
+; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0:%.*]] to i1
+; CHECK-NEXT: ret i1 [[RET]]
+;
+ %ret = trunc nsw i8 %1 to i1
+ ret i1 %ret
+}
+
+define i2 @neg_trunc_nsw_i2_non_zero(i8 %1) {
+; CHECK-LABEL: @neg_trunc_nsw_i2_non_zero(
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
+; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
+; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0]] to i2
+; CHECK-NEXT: ret i2 [[RET]]
+;
+ %3 = icmp ne i8 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %ret = trunc nsw i8 %1 to i2
+ ret i2 %ret
+}
More information about the llvm-commits
mailing list