[llvm] 96d6869 - [InstSimplify] Add additional tests for with op replaced fold (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 01:12:35 PDT 2023


Author: Nikita Popov
Date: 2023-07-18T10:12:28+02:00
New Revision: 96d686933256cecf7d3d6a02225138e2ca64971b

URL: https://github.com/llvm/llvm-project/commit/96d686933256cecf7d3d6a02225138e2ca64971b
DIFF: https://github.com/llvm/llvm-project/commit/96d686933256cecf7d3d6a02225138e2ca64971b.diff

LOG: [InstSimplify] Add additional tests for with op replaced fold (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 2b58a7489273cf..3c42803c92c507 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(


        


More information about the llvm-commits mailing list