From 998ececef0e28adc96edea5a288fd76c1f56187e Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 5 Dec 2018 23:09:33 +0000 Subject: [PATCH] [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. llvm-svn: 348423 --- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 6 ------ llvm/test/Transforms/InstCombine/scalarization.ll | 8 -------- llvm/test/Transforms/InstSimplify/extract-element.ll | 13 +++++++++++-- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 12e46a3..bc14f10 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -267,12 +267,6 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { 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(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(Index); diff --git a/llvm/test/Transforms/InstCombine/scalarization.ll b/llvm/test/Transforms/InstCombine/scalarization.ll index 9fbfc6f..ae8e156 100644 --- a/llvm/test/Transforms/InstCombine/scalarization.ll +++ b/llvm/test/Transforms/InstCombine/scalarization.ll @@ -97,14 +97,6 @@ define i32 @extelt_binop_binop_insertelt(<4 x i32> %A, <4 x i32> %B, i32 %f) { 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> , 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> , i32 [[Y:%.*]] diff --git a/llvm/test/Transforms/InstSimplify/extract-element.ll b/llvm/test/Transforms/InstSimplify/extract-element.ll index 0514789..ef12a78 100644 --- a/llvm/test/Transforms/InstSimplify/extract-element.ll +++ b/llvm/test/Transforms/InstSimplify/extract-element.ll @@ -39,9 +39,18 @@ define i129 @vec_extract_undef_index(<3 x i129> %a) { 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> , i32 %y + ret float %r +} + -- 2.7.4