[llvm] r348423 - [InstCombine] remove dead code from visitExtractElement
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 5 15:09:33 PST 2018
Author: spatel
Date: Wed Dec 5 15:09:33 2018
New Revision: 348423
URL: http://llvm.org/viewvc/llvm-project?rev=348423&view=rev
Log:
[InstCombine] remove dead code from visitExtractElement
Extracting from a splat constant is always handled by InstSimplify.
Move the test for this from InstCombine to InstSimplify to make
sure that stays true.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/trunk/test/Transforms/InstCombine/scalarization.ll
llvm/trunk/test/Transforms/InstSimplify/extract-element.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=348423&r1=348422&r2=348423&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Wed Dec 5 15:09:33 2018
@@ -267,12 +267,6 @@ Instruction *InstCombiner::visitExtractE
SQ.getWithInstruction(&EI)))
return replaceInstUsesWith(EI, V);
- // If vector val is constant with all elements the same, replace EI with
- // that element. We handle a known element # below.
- if (auto *C = dyn_cast<Constant>(SrcVec))
- if (cheapToScalarize(C, false))
- return replaceInstUsesWith(EI, C->getAggregateElement(0U));
-
// If extracting a specified index from the vector, see if we can recursively
// find a previously computed scalar that was inserted into the vector.
auto *IndexC = dyn_cast<ConstantInt>(Index);
Modified: llvm/trunk/test/Transforms/InstCombine/scalarization.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/scalarization.ll?rev=348423&r1=348422&r2=348423&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/scalarization.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/scalarization.ll Wed Dec 5 15:09:33 2018
@@ -97,14 +97,6 @@ define i32 @extelt_binop_binop_insertelt
ret i32 %E
}
-define float @extract_element_splat_constant_vector_variable_index(i32 %y) {
-; CHECK-LABEL: @extract_element_splat_constant_vector_variable_index(
-; CHECK-NEXT: ret float 2.000000e+00
-;
- %r = extractelement <4 x float> <float 2.0, float 2.0, float 2.0, float 2.0>, i32 %y
- ret float %r
-}
-
define float @extract_element_constant_vector_variable_index(i32 %y) {
; CHECK-LABEL: @extract_element_constant_vector_variable_index(
; CHECK-NEXT: [[R:%.*]] = extractelement <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>, i32 [[Y:%.*]]
Modified: llvm/trunk/test/Transforms/InstSimplify/extract-element.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/extract-element.ll?rev=348423&r1=348422&r2=348423&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/extract-element.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/extract-element.ll Wed Dec 5 15:09:33 2018
@@ -39,9 +39,18 @@ define i129 @vec_extract_undef_index(<3
define i129 @vec_extract_in_bounds(<3 x i129> %a) {
; CHECK-LABEL: @vec_extract_in_bounds(
-; CHECK-NEXT: %E1 = extractelement <3 x i129> %a, i129 2
-; CHECK-NEXT: ret i129 %E1
+; CHECK-NEXT: [[E1:%.*]] = extractelement <3 x i129> [[A:%.*]], i129 2
+; CHECK-NEXT: ret i129 [[E1]]
;
%E1 = extractelement <3 x i129> %a, i129 2
ret i129 %E1
}
+
+define float @extract_element_splat_constant_vector_variable_index(i32 %y) {
+; CHECK-LABEL: @extract_element_splat_constant_vector_variable_index(
+; CHECK-NEXT: ret float 2.000000e+00
+;
+ %r = extractelement <4 x float> <float 2.0, float 2.0, float 2.0, float 2.0>, i32 %y
+ ret float %r
+}
+
More information about the llvm-commits
mailing list