blob: f82b2fc29ac548a4f450afcb21d24b84e3f9544c [file] [log] [blame]
Chris Lattner08c7fd12005-08-10 00:48:11 +00001; Check that variable strides are reduced to adds instead of multiplies.
Dan Gohman18800922009-09-11 18:01:28 +00002; RUN: opt < %s -loop-reduce -S | not grep mul
Chris Lattner08c7fd12005-08-10 00:48:11 +00003
Mehdi Amini46a43552015-03-04 18:43:29 +00004; Provide legal integer types.
5target datalayout = "n8:16:32:64"
6
Tanya Lattnerab7872c2008-03-19 07:28:33 +00007declare i1 @pred(i32)
Chris Lattner08c7fd12005-08-10 00:48:11 +00008
Tanya Lattnerab7872c2008-03-19 07:28:33 +00009define void @test([10000 x i32]* %P, i32 %STRIDE) {
10; <label>:0
Chris Lattner08c7fd12005-08-10 00:48:11 +000011 br label %Loop
Tanya Lattnerab7872c2008-03-19 07:28:33 +000012Loop: ; preds = %Loop, %0
13 %INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=2]
14 %Idx = mul i32 %INDVAR, %STRIDE ; <i32> [#uses=1]
15 %cond = call i1 @pred( i32 %Idx ) ; <i1> [#uses=1]
16 %INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
17 br i1 %cond, label %Loop, label %Out
18Out: ; preds = %Loop
Chris Lattner08c7fd12005-08-10 00:48:11 +000019 ret void
20}
Tanya Lattnerab7872c2008-03-19 07:28:33 +000021