From e6ed9807f6083de78dbfda1e746ee8e25169e8fb Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 30 Aug 2017 21:11:46 +0000 Subject: [PATCH] [InstCombine] add more vector demand examples; NFC See D37236 for discussion. It seems unlikely that we actually want/need to do this kind of folding in InstCombine in the long run, but moving everything will be a bigger follow-up step. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312172 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/vec_demanded_elts.ll | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/Transforms/InstCombine/vec_demanded_elts.ll b/test/Transforms/InstCombine/vec_demanded_elts.ll index 9fe1b87e337..bc935c89bb9 100644 --- a/test/Transforms/InstCombine/vec_demanded_elts.ll +++ b/test/Transforms/InstCombine/vec_demanded_elts.ll @@ -172,3 +172,37 @@ define <4 x float> @inselt_shuf_no_demand_commute(float %a1, float %a2, float %a ret <4 x float> %shuffle } +; FIXME: The add uses 'out012' giving it multiple uses after the shuffle is transformed to also +; use 'out012'. The analysis should be able to see past that. + +define <4 x i32> @inselt_shuf_no_demand_multiuse(i32 %a0, i32 %a1, <4 x i32> %b) { +; CHECK-LABEL: @inselt_shuf_no_demand_multiuse( +; CHECK-NEXT: [[OUT0:%.*]] = insertelement <4 x i32> undef, i32 %a0, i32 0 +; CHECK-NEXT: [[OUT01:%.*]] = insertelement <4 x i32> [[OUT0]], i32 %a1, i32 1 +; CHECK-NEXT: [[OUT012:%.*]] = insertelement <4 x i32> [[OUT01]], i32 %a0, i32 2 +; CHECK-NEXT: [[FOO:%.*]] = add <4 x i32> [[OUT012]], %b +; CHECK-NEXT: ret <4 x i32> [[FOO]] +; + %out0 = insertelement <4 x i32> undef, i32 %a0, i32 0 + %out01 = insertelement <4 x i32> %out0, i32 %a1, i32 1 + %out012 = insertelement <4 x i32> %out01, i32 %a0, i32 2 + %foo = add <4 x i32> %out012, %b + %out0123 = insertelement <4 x i32> %foo, i32 %a1, i32 3 + %shuffle = shufflevector <4 x i32> %out0123, <4 x i32> undef, <4 x i32> + ret <4 x i32> %shuffle +} + +; FIXME: We should be able to look past the bogus use of 'out12' and kill 'out1'. + +define <4 x float> @inselt_shuf_no_demand_bogus_insert_index_in_chain(float %a1, float %a2, float %a3, i32 %variable_index) { +; CHECK-LABEL: @inselt_shuf_no_demand_bogus_insert_index_in_chain( +; CHECK-NEXT: [[OUT1:%.*]] = insertelement <4 x float> undef, float %a1, i32 1 +; CHECK-NEXT: ret <4 x float> [[OUT1]] +; + %out1 = insertelement <4 x float> undef, float %a1, i32 1 + %out12 = insertelement <4 x float> %out1, float %a2, i32 undef ; something unexpected + %out123 = insertelement <4 x float> %out12, float %a3, i32 3 + %shuffle = shufflevector <4 x float> %out123, <4 x float> undef, <4 x i32> + ret <4 x float> %shuffle +} + -- 2.50.1