[llvm] 034df6f - [InstCombine][NFC] Add extractelement tests
Thomas Symalla via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 03:56:01 PST 2022
Author: Thomas Symalla
Date: 2022-11-14T12:55:39+01:00
New Revision: 034df6f7323a82589a6278c5a410c46abc233502
URL: https://github.com/llvm/llvm-project/commit/034df6f7323a82589a6278c5a410c46abc233502
DIFF: https://github.com/llvm/llvm-project/commit/034df6f7323a82589a6278c5a410c46abc233502.diff
LOG: [InstCombine][NFC] Add extractelement tests
Added:
Modified:
llvm/test/Transforms/InstCombine/extractelement.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/extractelement.ll b/llvm/test/Transforms/InstCombine/extractelement.ll
index 1e8d049c96e7d..aa236c57ee703 100644
--- a/llvm/test/Transforms/InstCombine/extractelement.ll
+++ b/llvm/test/Transforms/InstCombine/extractelement.ll
@@ -782,3 +782,46 @@ define i1 @bit_extract_cmp(i64 %x) {
%r = fcmp oeq float %e, 0.0
ret i1 %r
}
+
+define i32 @extelt_select_const_operand_vector(i1 %c) {
+; ANY-LABEL: @extelt_select_const_operand_vector(
+; ANY-NEXT: [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 poison, i32 poison, i32 4>, <3 x i32> <i32 poison, i32 poison, i32 7>
+; ANY-NEXT: [[R:%.*]] = extractelement <3 x i32> [[S]], i64 2
+; ANY-NEXT: ret i32 [[R]]
+;
+ %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>
+ %r = extractelement <3 x i32> %s, i32 2
+ ret i32 %r
+}
+
+define i32 @extelt_select_const_operand_extractelt_use(i1 %c) {
+; ANY-LABEL: @extelt_select_const_operand_extractelt_use(
+; ANY-NEXT: [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 poison, i32 poison, i32 4>, <3 x i32> <i32 poison, i32 poison, i32 7>
+; ANY-NEXT: [[E:%.*]] = extractelement <3 x i32> [[S]], i64 2
+; ANY-NEXT: [[M:%.*]] = shl i32 [[E]], 1
+; ANY-NEXT: [[M_2:%.*]] = shl i32 [[E]], 2
+; ANY-NEXT: [[R:%.*]] = mul i32 [[M]], [[M_2]]
+; ANY-NEXT: ret i32 [[R]]
+;
+ %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>
+ %e = extractelement <3 x i32> %s, i32 2
+ %m = mul i32 %e, 2
+ %m.2 = mul i32 %e, 4
+ %r = mul i32 %m, %m.2
+ ret i32 %r
+}
+
+define i32 @extelt_select_const_operand_select_use(i1 %c) {
+; ANY-LABEL: @extelt_select_const_operand_select_use(
+; ANY-NEXT: [[S:%.*]] = select i1 [[C:%.*]], <3 x i32> <i32 poison, i32 3, i32 4>, <3 x i32> <i32 poison, i32 6, i32 7>
+; ANY-NEXT: [[E:%.*]] = extractelement <3 x i32> [[S]], i64 2
+; ANY-NEXT: [[E_2:%.*]] = extractelement <3 x i32> [[S]], i64 1
+; ANY-NEXT: [[R:%.*]] = mul i32 [[E]], [[E_2]]
+; ANY-NEXT: ret i32 [[R]]
+;
+ %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>
+ %e = extractelement <3 x i32> %s, i32 2
+ %e.2 = extractelement <3 x i32> %s, i32 1
+ %r = mul i32 %e, %e.2
+ ret i32 %r
+}
More information about the llvm-commits
mailing list