[llvm] cd264f0 - [InstSimplify] Test select bit test with trunc to i1 (NFC)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 14:52:48 PST 2025
Author: Andreas Jonson
Date: 2025-01-13T23:52:23+01:00
New Revision: cd264f09a4d2f25d75436abdeeb757c412c3a75c
URL: https://github.com/llvm/llvm-project/commit/cd264f09a4d2f25d75436abdeeb757c412c3a75c
DIFF: https://github.com/llvm/llvm-project/commit/cd264f09a4d2f25d75436abdeeb757c412c3a75c.diff
LOG: [InstSimplify] Test select bit test with trunc to i1 (NFC)
Added:
Modified:
llvm/test/Transforms/InstSimplify/select.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll
index 5f160aa1658616..40539b8ade388b 100644
--- a/llvm/test/Transforms/InstSimplify/select.ll
+++ b/llvm/test/Transforms/InstSimplify/select.ll
@@ -1749,3 +1749,31 @@ define <4 x i32> @select_vector_cmp_with_bitcasts(<2 x i64> %x, <4 x i32> %y) {
%sel = select <4 x i1> %cmp, <4 x i32> %sub.bc, <4 x i32> zeroinitializer
ret <4 x i32> %sel
}
+
+define i8 @bittest_trunc_or(i8 %x) {
+; CHECK-LABEL: @bittest_trunc_or(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X1:%.*]] to i1
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X1]], 1
+; CHECK-NEXT: [[X:%.*]] = select i1 [[TRUNC]], i8 [[OR]], i8 [[X1]]
+; CHECK-NEXT: ret i8 [[X]]
+;
+ %trunc = trunc i8 %x to i1
+ %or = or i8 %x, 1
+ %cond = select i1 %trunc, i8 %or, i8 %x
+ ret i8 %cond
+}
+
+define i8 @bittest_trunc_not_or(i8 %x) {
+; CHECK-LABEL: @bittest_trunc_not_or(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[TRUNC]], true
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X]], 1
+; CHECK-NEXT: [[COND:%.*]] = select i1 [[NOT]], i8 [[OR]], i8 [[X]]
+; CHECK-NEXT: ret i8 [[COND]]
+;
+ %trunc = trunc i8 %x to i1
+ %not = xor i1 %trunc, true
+ %or = or i8 %x, 1
+ %cond = select i1 %not, i8 %or, i8 %x
+ ret i8 %cond
+}
More information about the llvm-commits
mailing list