From 5141435d232be4ff1efb841667c931c89525c89f Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 23 Oct 2018 14:07:39 +0000 Subject: [SLSR] use 'match' to simplify code; NFC This pass could probably be modified slightly to allow vector splat transforms for practically no cost, but it only works on scalars for now. So the use of the newer 'match' API should make no functional difference. llvm-svn: 345030 --- .../StraightLineStrengthReduce/slsr-add.ll | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'llvm/test/Transforms/StraightLineStrengthReduce') diff --git a/llvm/test/Transforms/StraightLineStrengthReduce/slsr-add.ll b/llvm/test/Transforms/StraightLineStrengthReduce/slsr-add.ll index c3bffb270af..92af617dab8 100644 --- a/llvm/test/Transforms/StraightLineStrengthReduce/slsr-add.ll +++ b/llvm/test/Transforms/StraightLineStrengthReduce/slsr-add.ll @@ -99,6 +99,34 @@ define void @stride_is_minus_2s(i32 %b, i32 %s) { ret void } +; TODO: This pass is targeted at simple address-calcs, so it is artificially limited to +; match scalar values. The code could be modified to handle vector types too. + +define void @stride_is_minus_2s_vec(<2 x i32> %b, <2 x i32> %s) { +; CHECK-LABEL: @stride_is_minus_2s_vec( +; CHECK-NEXT: [[S6:%.*]] = mul <2 x i32> [[S:%.*]], +; CHECK-NEXT: [[T1:%.*]] = add <2 x i32> [[B:%.*]], [[S6]] +; CHECK-NEXT: call void @voo(<2 x i32> [[T1]]) +; CHECK-NEXT: [[S4:%.*]] = shl <2 x i32> [[S]], +; CHECK-NEXT: [[T2:%.*]] = add <2 x i32> [[B]], [[S4]] +; CHECK-NEXT: call void @voo(<2 x i32> [[T2]]) +; CHECK-NEXT: [[S2:%.*]] = shl <2 x i32> [[S]], +; CHECK-NEXT: [[T3:%.*]] = add <2 x i32> [[B]], [[S2]] +; CHECK-NEXT: call void @voo(<2 x i32> [[T3]]) +; CHECK-NEXT: ret void +; + %s6 = mul <2 x i32> %s, + %t1 = add <2 x i32> %b, %s6 + call void @voo(<2 x i32> %t1) + %s4 = shl <2 x i32> %s, + %t2 = add <2 x i32> %b, %s4 + call void @voo(<2 x i32> %t2) + %s2 = shl <2 x i32> %s, + %t3 = add <2 x i32> %b, %s2 + call void @voo(<2 x i32> %t3) + ret void +} + ; t = b + (s << 3); ; foo(t); ; foo(b + s); @@ -140,4 +168,5 @@ define void @slsr_strided_add_128bit(i128 %b, i128 %s) { } declare void @foo(i32) +declare void @voo(<2 x i32>) declare void @bar(i128) -- cgit v1.2.3