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
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);
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:%.*]]
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
+}
+