blob: c05b19d8fdd54031b2ed2ad5542fb987ce5b52ed [file] [log] [blame]
Dan Gohman18800922009-09-11 18:01:28 +00001; RUN: opt < %s -loop-reduce -S | not grep mul
Chris Lattner67315dc2005-10-30 05:14:02 +00002
Mehdi Amini46a43552015-03-04 18:43:29 +00003; Provide legal integer types.
4target datalayout = "n8:16:32:64"
5
Chris Lattner67315dc2005-10-30 05:14:02 +00006; Make sure we don't get a multiply by 6 in this loop.
7
Tanya Lattnerab7872c2008-03-19 07:28:33 +00008define i32 @foo(i32 %A, i32 %B, i32 %C, i32 %D) {
Chris Lattner67315dc2005-10-30 05:14:02 +00009entry:
Tanya Lattnerab7872c2008-03-19 07:28:33 +000010 %tmp.5 = icmp sgt i32 %C, 0 ; <i1> [#uses=1]
11 %tmp.25 = and i32 %A, 1 ; <i32> [#uses=1]
Chris Lattner67315dc2005-10-30 05:14:02 +000012 br label %loopentry.1
Chris Lattner67315dc2005-10-30 05:14:02 +000013loopentry.1: ; preds = %loopexit.1, %entry
Tanya Lattnerab7872c2008-03-19 07:28:33 +000014 %indvar20 = phi i32 [ 0, %entry ], [ %indvar.next21, %loopexit.1 ] ; <i32> [#uses=2]
15 %k.1 = phi i32 [ 0, %entry ], [ %k.1.3, %loopexit.1 ] ; <i32> [#uses=2]
16 br i1 %tmp.5, label %no_exit.1.preheader, label %loopexit.1
Chris Lattner67315dc2005-10-30 05:14:02 +000017no_exit.1.preheader: ; preds = %loopentry.1
Tanya Lattnerab7872c2008-03-19 07:28:33 +000018 %i.0.0 = bitcast i32 %indvar20 to i32 ; <i32> [#uses=1]
19 %tmp.9 = mul i32 %i.0.0, 6 ; <i32> [#uses=1]
Chris Lattner67315dc2005-10-30 05:14:02 +000020 br label %no_exit.1.outer
Chris Lattner67315dc2005-10-30 05:14:02 +000021no_exit.1.outer: ; preds = %cond_true, %no_exit.1.preheader
Tanya Lattnerab7872c2008-03-19 07:28:33 +000022 %k.1.2.ph = phi i32 [ %k.1, %no_exit.1.preheader ], [ %k.09, %cond_true ] ; <i32> [#uses=2]
23 %j.1.2.ph = phi i32 [ 0, %no_exit.1.preheader ], [ %inc.1, %cond_true ] ; <i32> [#uses=1]
Chris Lattner67315dc2005-10-30 05:14:02 +000024 br label %no_exit.1
Chris Lattner67315dc2005-10-30 05:14:02 +000025no_exit.1: ; preds = %cond_continue, %no_exit.1.outer
Tanya Lattnerab7872c2008-03-19 07:28:33 +000026 %indvar.ui = phi i32 [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; <i32> [#uses=2]
27 %indvar = bitcast i32 %indvar.ui to i32 ; <i32> [#uses=1]
28 %j.1.2 = add i32 %indvar, %j.1.2.ph ; <i32> [#uses=2]
29 %tmp.11 = add i32 %j.1.2, %tmp.9 ; <i32> [#uses=1]
30 %tmp.12 = trunc i32 %tmp.11 to i8 ; <i8> [#uses=1]
31 %shift.upgrd.1 = zext i8 %tmp.12 to i32 ; <i32> [#uses=1]
32 %tmp.13 = shl i32 %D, %shift.upgrd.1 ; <i32> [#uses=2]
33 %tmp.15 = icmp eq i32 %tmp.13, %B ; <i1> [#uses=1]
34 %inc.1 = add i32 %j.1.2, 1 ; <i32> [#uses=3]
35 br i1 %tmp.15, label %cond_true, label %cond_continue
Chris Lattner67315dc2005-10-30 05:14:02 +000036cond_true: ; preds = %no_exit.1
Tanya Lattnerab7872c2008-03-19 07:28:33 +000037 %tmp.26 = and i32 %tmp.25, %tmp.13 ; <i32> [#uses=1]
38 %k.09 = add i32 %tmp.26, %k.1.2.ph ; <i32> [#uses=2]
39 %tmp.517 = icmp slt i32 %inc.1, %C ; <i1> [#uses=1]
40 br i1 %tmp.517, label %no_exit.1.outer, label %loopexit.1
Chris Lattner67315dc2005-10-30 05:14:02 +000041cond_continue: ; preds = %no_exit.1
Tanya Lattnerab7872c2008-03-19 07:28:33 +000042 %tmp.519 = icmp slt i32 %inc.1, %C ; <i1> [#uses=1]
43 %indvar.next = add i32 %indvar.ui, 1 ; <i32> [#uses=1]
44 br i1 %tmp.519, label %no_exit.1, label %loopexit.1
Chris Lattner67315dc2005-10-30 05:14:02 +000045loopexit.1: ; preds = %cond_continue, %cond_true, %loopentry.1
Tanya Lattnerab7872c2008-03-19 07:28:33 +000046 %k.1.3 = phi i32 [ %k.1, %loopentry.1 ], [ %k.09, %cond_true ], [ %k.1.2.ph, %cond_continue ] ; <i32> [#uses=2]
47 %indvar.next21 = add i32 %indvar20, 1 ; <i32> [#uses=2]
48 %exitcond = icmp eq i32 %indvar.next21, 4 ; <i1> [#uses=1]
49 br i1 %exitcond, label %loopexit.0, label %loopentry.1
Chris Lattner67315dc2005-10-30 05:14:02 +000050loopexit.0: ; preds = %loopexit.1
Tanya Lattnerab7872c2008-03-19 07:28:33 +000051 ret i32 %k.1.3
Chris Lattner67315dc2005-10-30 05:14:02 +000052}