diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2016-09-02 09:00:53 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-09-02 09:00:53 +0000 |
| commit | ed27d69037253116afb25c94ed08051e3aa35828 (patch) | |
| tree | 5184eef062f6e5f50a616ccc1e30b91f2d7c000f /llvm/test/Transforms/InstCombine | |
| parent | d8dfeec019e053ffc3c8205378c24a7023856a0d (diff) | |
| download | bcm5719-llvm-ed27d69037253116afb25c94ed08051e3aa35828.tar.gz bcm5719-llvm-ed27d69037253116afb25c94ed08051e3aa35828.zip | |
[InstCombine] Add test for insertelementinsts with constants.
Added a tests that shows that several insertelementinsts with constant
indexes/data are not folded into a single shuffleinst.
llvm-svn: 280474
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/vector_insertelt_shuffle.ll | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/vector_insertelt_shuffle.ll b/llvm/test/Transforms/InstCombine/vector_insertelt_shuffle.ll new file mode 100644 index 00000000000..9b45962569a --- /dev/null +++ b/llvm/test/Transforms/InstCombine/vector_insertelt_shuffle.ll @@ -0,0 +1,77 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instcombine -S | FileCheck %s + +define<4 x float> @foo(<4 x float> %x) { + %ins1 = insertelement<4 x float> %x, float 1.0, i32 1 + %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 + ret<4 x float> %ins2 +} + +; FIXME: insertelements should fold to shuffle +; CHECK-LABEL: @foo +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 1 +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 +; CHECK-NEXT: ret <4 x float> % + +define<4 x float> @bar(<4 x float> %x, float %a) { + %ins1 = insertelement<4 x float> %x, float %a, i32 1 + %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 + ret<4 x float> %ins2 +} + +; CHECK-LABEL: @bar +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 1 +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 +; CHECK-NEXT: ret <4 x float> % + +define<4 x float> @baz(<4 x float> %x, i32 %a) { + %ins1 = insertelement<4 x float> %x, float 1.0, i32 1 + %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 %a + ret<4 x float> %ins2 +} + +; CHECK-LABEL: @baz +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 1 +; CHECK-NEXT: insertelement <4 x float> %ins1, float 2.000000e+00, i32 % +; CHECK-NEXT: ret <4 x float> % + +define<4 x float> @bazz(<4 x float> %x, i32 %a) { + %ins1 = insertelement<4 x float> %x, float 1.0, i32 3 + %ins2 = insertelement<4 x float> %ins1, float 5.0, i32 %a + %ins3 = insertelement<4 x float> %ins2, float 3.0, i32 2 + %ins4 = insertelement<4 x float> %ins3, float 1.0, i32 1 + %ins5 = insertelement<4 x float> %ins4, float 2.0, i32 2 + %ins6 = insertelement<4 x float> %ins5, float 7.0, i32 %a + ret<4 x float> %ins6 +} + +; FIXME: insertelements should fold to shuffle +; CHECK-LABEL: @bazz +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 3 +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 5.000000e+00, i32 % +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 1 +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 7.000000e+00, i32 % +; CHECK-NEXT: ret <4 x float> % + +define<4 x float> @bazzz(<4 x float> %x) { + %ins1 = insertelement<4 x float> %x, float 1.0, i32 5 + %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 + ret<4 x float> %ins2 +} + +; CHECK-LABEL: @bazzz +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 +; CHECK-NEXT: ret <4 x float> % + +define<4 x float> @bazzzz(<4 x float> %x) { + %ins1 = insertelement<4 x float> %x, float 1.0, i32 undef + %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 + ret<4 x float> %ins2 +} + +; CHECK-LABEL: @bazzzz +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 undef +; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 +; CHECK-NEXT: ret <4 x float> % + |

