diff options
author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2017-06-05 09:18:10 +0000 |
---|---|---|
committer | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2017-06-05 09:18:10 +0000 |
commit | 78819e0fd470e1f736891549491ef14f24c68fed (patch) | |
tree | 709bff390dac698360bff85dc3e3544c7981f86c /llvm/test | |
parent | 43e852fb79fe4a7bfca857d92b6b5d30c108cf45 (diff) | |
download | bcm5719-llvm-78819e0fd470e1f736891549491ef14f24c68fed.tar.gz bcm5719-llvm-78819e0fd470e1f736891549491ef14f24c68fed.zip |
[InstCombine] Fix extractelement use before def
This fixes a bug that can cause extractelements with operands that
haven't been defined yet to be inserted at a wrong point when
optimising insertelements.
Patch by Karl Hylen.
Differential Revision: https://reviews.llvm.org/D33449
llvm-svn: 304701
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll index 29f774c5f62..fb25c234279 100644 --- a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll +++ b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll @@ -260,3 +260,26 @@ bb2: %ins2 = insertelement <4 x float> %ins1, float %ext1, i32 3 ret <4 x float> %ins2 } + +; Don't insert extractelements from the wider vector before the def of the index operand. + +define <4 x i32> @extractelt_insertion(<2 x i32> %x, i32 %y) { +; CHECK-LABEL: @extractelt_insertion( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef> +; CHECK-NEXT: [[B:%.*]] = shufflevector <4 x i32> <i32 0, i32 0, i32 0, i32 undef>, <4 x i32> [[TMP0]], <4 x i32> <i32 0, i32 1, i32 2, i32 5> +; CHECK-NEXT: [[C:%.*]] = add i32 [[Y:%.*]], 3 +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[TMP0]], i32 [[C]] +; CHECK-NEXT: [[E:%.*]] = icmp eq i32 [[TMP1]], 0 +; CHECK-NEXT: [[RET:%.*]] = select i1 [[E]], <4 x i32> [[B]], <4 x i32> zeroinitializer +; CHECK-NEXT: ret <4 x i32> [[RET]] +; +entry: + %a = extractelement <2 x i32> %x, i32 1 + %b = insertelement <4 x i32> zeroinitializer, i32 %a, i64 3 + %c = add i32 %y, 3 + %d = extractelement <2 x i32> %x, i32 %c + %e = icmp eq i32 %d, 0 + %ret = select i1 %e, <4 x i32> %b, <4 x i32> zeroinitializer + ret <4 x i32> %ret +} |