[llvm] r312172 - [InstCombine] add more vector demand examples; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 30 14:11:46 PDT 2017
Author: spatel
Date: Wed Aug 30 14:11:46 2017
New Revision: 312172
URL: http://llvm.org/viewvc/llvm-project?rev=312172&view=rev
Log:
[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.
Modified:
llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll
Modified: llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll?rev=312172&r1=312171&r2=312172&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_demanded_elts.ll Wed Aug 30 14:11:46 2017
@@ -172,3 +172,37 @@ define <4 x float> @inselt_shuf_no_deman
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> <i32 0, i32 1, i32 undef, i32 undef>
+ 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> <i32 0, i32 undef, i32 undef, i32 undef>
+ ret <4 x float> %shuffle
+}
+
More information about the llvm-commits
mailing list