[llvm] 25dcee4 - [NFC] Pre commit test for fold trunc nuw X to i1 -> true IFF X != 0
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 8 06:02:58 PST 2024
Author: Andreas Jonson
Date: 2024-12-08T15:02:51+01:00
New Revision: 25dcee40422097bbdc9fb01224c4b06df13bb6ea
URL: https://github.com/llvm/llvm-project/commit/25dcee40422097bbdc9fb01224c4b06df13bb6ea
DIFF: https://github.com/llvm/llvm-project/commit/25dcee40422097bbdc9fb01224c4b06df13bb6ea.diff
LOG: [NFC] Pre commit test for fold trunc nuw 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 15533346b32ece..f29ecb8c313738 100644
--- a/llvm/test/Transforms/InstCombine/trunc.ll
+++ b/llvm/test/Transforms/InstCombine/trunc.ll
@@ -1124,3 +1124,51 @@ loop:
exit:
ret void
}
+
+define i1 @trunc_nuw_i1_non_zero(i8 %1) {
+; CHECK-LABEL: @trunc_nuw_i1_non_zero(
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
+; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
+; CHECK-NEXT: [[RET:%.*]] = trunc nuw i8 [[TMP0]] to i1
+; CHECK-NEXT: ret i1 [[RET]]
+;
+ %3 = icmp ne i8 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %ret = trunc nuw i8 %1 to i1
+ ret i1 %ret
+}
+
+define i1 @neg_trunc_nuw_i1_maybe_zero(i8 %1) {
+; CHECK-LABEL: @neg_trunc_nuw_i1_maybe_zero(
+; CHECK-NEXT: [[RET:%.*]] = trunc nuw i8 [[TMP0:%.*]] to i1
+; CHECK-NEXT: ret i1 [[RET]]
+;
+ %ret = trunc nuw i8 %1 to i1
+ ret i1 %ret
+}
+
+define i2 @neg_trunc_nuw_i2_non_zero(i8 %1) {
+; CHECK-LABEL: @neg_trunc_nuw_i2_non_zero(
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
+; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
+; CHECK-NEXT: [[RET:%.*]] = trunc nuw i8 [[TMP0]] to i2
+; CHECK-NEXT: ret i2 [[RET]]
+;
+ %3 = icmp ne i8 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %ret = trunc nuw i8 %1 to i2
+ ret i2 %ret
+}
+
+define i1 @neg_trunc_i1_non_zero(i8 %1) {
+; CHECK-LABEL: @neg_trunc_i1_non_zero(
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
+; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
+; CHECK-NEXT: [[RET:%.*]] = trunc i8 [[TMP0]] to i1
+; CHECK-NEXT: ret i1 [[RET]]
+;
+ %3 = icmp ne i8 %1, 0
+ tail call void @llvm.assume(i1 %3)
+ %ret = trunc i8 %1 to i1
+ ret i1 %ret
+}
More information about the llvm-commits
mailing list