llvm.org GIT mirror llvm / 7c48342
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348423 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 10 months ago
3 changed file(s) with 11 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
265265 if (Value *V = SimplifyExtractElementInst(SrcVec, Index,
266266 SQ.getWithInstruction(&EI)))
267267 return replaceInstUsesWith(EI, V);
268
269 // If vector val is constant with all elements the same, replace EI with
270 // that element. We handle a known element # below.
271 if (auto *C = dyn_cast(SrcVec))
272 if (cheapToScalarize(C, false))
273 return replaceInstUsesWith(EI, C->getAggregateElement(0U));
274268
275269 // If extracting a specified index from the vector, see if we can recursively
276270 // find a previously computed scalar that was inserted into the vector.
9696 ret i32 %E
9797 }
9898
99 define float @extract_element_splat_constant_vector_variable_index(i32 %y) {
100 ; CHECK-LABEL: @extract_element_splat_constant_vector_variable_index(
101 ; CHECK-NEXT: ret float 2.000000e+00
102 ;
103 %r = extractelement <4 x float> , i32 %y
104 ret float %r
105 }
106
10799 define float @extract_element_constant_vector_variable_index(i32 %y) {
108100 ; CHECK-LABEL: @extract_element_constant_vector_variable_index(
109101 ; CHECK-NEXT: [[R:%.*]] = extractelement <4 x float> , i32 [[Y:%.*]]
3838
3939 define i129 @vec_extract_in_bounds(<3 x i129> %a) {
4040 ; CHECK-LABEL: @vec_extract_in_bounds(
41 ; CHECK-NEXT: %E1 = extractelement <3 x i129> %a, i129 2
42 ; CHECK-NEXT: ret i129 %E1
41 ; CHECK-NEXT: [[E1:%.*]] = extractelement <3 x i129> [[A:%.*]], i129 2
42 ; CHECK-NEXT: ret i129 [[E1]]
4343 ;
4444 %E1 = extractelement <3 x i129> %a, i129 2
4545 ret i129 %E1
4646 }
47
48 define float @extract_element_splat_constant_vector_variable_index(i32 %y) {
49 ; CHECK-LABEL: @extract_element_splat_constant_vector_variable_index(
50 ; CHECK-NEXT: ret float 2.000000e+00
51 ;
52 %r = extractelement <4 x float> , i32 %y
53 ret float %r
54 }
55