[llvm] e88cd40 - [InstCombine] Add tests for simplification based on select known bits (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 05:33:06 PDT 2024
Author: Nikita Popov
Date: 2024-07-01T14:32:57+02:00
New Revision: e88cd40d477f7194377a5df7a5a2f0f1b5376216
URL: https://github.com/llvm/llvm-project/commit/e88cd40d477f7194377a5df7a5a2f0f1b5376216
DIFF: https://github.com/llvm/llvm-project/commit/e88cd40d477f7194377a5df7a5a2f0f1b5376216.diff
LOG: [InstCombine] Add tests for simplification based on select known bits (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/select.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index 192d7a9629466..63a4f74cbaaea 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -4666,3 +4666,50 @@ define i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {
%sel = select i1 %x, i8 0, i8 %shl.fr
ret i8 %sel
}
+
+define i8 @select_knownbits_simplify(i8 noundef %x) {
+; CHECK-LABEL: @select_knownbits_simplify(
+; CHECK-NEXT: [[X_LO:%.*]] = and i8 [[X:%.*]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X_LO]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], -2
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i8 [[AND]], i8 0
+; CHECK-NEXT: ret i8 [[RES]]
+;
+ %x.lo = and i8 %x, 1
+ %cmp = icmp eq i8 %x.lo, 0
+ %and = and i8 %x, -2
+ %res = select i1 %cmp, i8 %and, i8 0
+ ret i8 %res
+}
+
+define i8 @select_knownbits_simplify_nested(i8 noundef %x) {
+; CHECK-LABEL: @select_knownbits_simplify_nested(
+; CHECK-NEXT: [[X_LO:%.*]] = and i8 [[X:%.*]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X_LO]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], -2
+; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[AND]], [[AND]]
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i8 [[MUL]], i8 0
+; CHECK-NEXT: ret i8 [[RES]]
+;
+ %x.lo = and i8 %x, 1
+ %cmp = icmp eq i8 %x.lo, 0
+ %and = and i8 %x, -2
+ %mul = mul i8 %and, %and
+ %res = select i1 %cmp, i8 %mul, i8 0
+ ret i8 %res
+}
+
+define i8 @select_knownbits_simplify_missing_noundef(i8 %x) {
+; CHECK-LABEL: @select_knownbits_simplify_missing_noundef(
+; CHECK-NEXT: [[X_LO:%.*]] = and i8 [[X:%.*]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X_LO]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], -2
+; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i8 [[AND]], i8 0
+; CHECK-NEXT: ret i8 [[RES]]
+;
+ %x.lo = and i8 %x, 1
+ %cmp = icmp eq i8 %x.lo, 0
+ %and = and i8 %x, -2
+ %res = select i1 %cmp, i8 %and, i8 0
+ ret i8 %res
+}
More information about the llvm-commits
mailing list