diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-09-21 14:43:49 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-09-21 14:43:49 +0000 |
| commit | 72d627e5ec293611741ed46271afeebf55a23e55 (patch) | |
| tree | e409ccf7938053d2e73e706c241ef4f80ab9ff25 | |
| parent | 19262fc5966ab569f21f3d440f8b001bca666f17 (diff) | |
| download | bcm5719-llvm-72d627e5ec293611741ed46271afeebf55a23e55.tar.gz bcm5719-llvm-72d627e5ec293611741ed46271afeebf55a23e55.zip | |
[InstCombine] add tests for extractelement; NFC
There are folds under visitExtractElementInst() that don't appear
to have any test coverage, so adding a few basic cases here.
llvm-svn: 342740
| -rw-r--r-- | llvm/test/Transforms/InstCombine/scalarization.ll | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/scalarization.ll b/llvm/test/Transforms/InstCombine/scalarization.ll index cac1e4dbb03..3bfdfd2885b 100644 --- a/llvm/test/Transforms/InstCombine/scalarization.ll +++ b/llvm/test/Transforms/InstCombine/scalarization.ll @@ -56,3 +56,31 @@ define float @extract_element_constant_index(<4 x float> %x) { ret float %r } +define float @extract_element_variable_index(<4 x float> %x, i32 %y) { +; CHECK-LABEL: @extract_element_variable_index( +; CHECK-NEXT: [[R_LHS:%.*]] = extractelement <4 x float> [[X:%.*]], i32 [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = fadd float [[R_LHS]], 1.000000e+00 +; CHECK-NEXT: ret float [[R]] +; + %add = fadd <4 x float> %x, <float 1.0, float 1.0, float 1.0, float 1.0> + %r = extractelement <4 x float> %add, i32 %y + ret float %r +} + +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:%.*]] +; CHECK-NEXT: ret float [[R]] +; + %r = extractelement <4 x float> <float 1.0, float 2.0, float 3.0, float 4.0>, i32 %y + ret float %r +} + |

