aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-07-18 10:11:57 +0200
committerNikita Popov <npopov@redhat.com>2023-07-18 10:12:28 +0200
commit96d686933256cecf7d3d6a02225138e2ca64971b (patch)
tree339336dc0d2fdbecc36bbaadf48313d2a1e899e4 /llvm
parent447bb5bee402eab94987ebbd8f29d696f946ba9e (diff)
downloadllvm-96d686933256cecf7d3d6a02225138e2ca64971b.zip
llvm-96d686933256cecf7d3d6a02225138e2ca64971b.tar.gz
llvm-96d686933256cecf7d3d6a02225138e2ca64971b.tar.bz2
[InstSimplify] Add additional tests for with op replaced fold (NFC)
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/Transforms/InstSimplify/select.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll
index 2b58a74..3c42803c 100644
--- a/llvm/test/Transforms/InstSimplify/select.ll
+++ b/llvm/test/Transforms/InstSimplify/select.ll
@@ -1207,6 +1207,36 @@ define i8 @select_eq_xor_recursive_allow_refinement(i8 %a, i8 %b) {
ret i8 %sel
}
+define i8 @select_eq_mul_absorber(i8 %x, i8 noundef %y) {
+; CHECK-LABEL: @select_eq_mul_absorber(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 1
+; CHECK-NEXT: [[ADD:%.*]] = add i8 [[X]], -1
+; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[ADD]], [[Y:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i8 0, i8 [[MUL]]
+; CHECK-NEXT: ret i8 [[SEL]]
+;
+ %cmp = icmp eq i8 %x, 1
+ %add = add i8 %x, -1
+ %mul = mul i8 %add, %y
+ %sel = select i1 %cmp, i8 0, i8 %mul
+ ret i8 %sel
+}
+
+define i8 @select_eq_mul_not_absorber(i8 %x, i8 noundef %y) {
+; CHECK-LABEL: @select_eq_mul_not_absorber(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
+; CHECK-NEXT: [[ADD:%.*]] = add i8 [[X]], -1
+; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[ADD]], [[Y:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i8 0, i8 [[MUL]]
+; CHECK-NEXT: ret i8 [[SEL]]
+;
+ %cmp = icmp eq i8 %x, 0
+ %add = add i8 %x, -1
+ %mul = mul i8 %add, %y
+ %sel = select i1 %cmp, i8 0, i8 %mul
+ ret i8 %sel
+}
+
; Vector to scalar options should be treated as lane-crossing.
define <2 x i8> @select_eq_vector_insert_extract(<2 x i8> %a, <2 x i8> %b) {
; CHECK-LABEL: @select_eq_vector_insert_extract(