Reid Spencer | 69ccadd | 2006-12-02 04:23:10 +0000 | [diff] [blame] | 1 | ; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | not grep mul |
Chris Lattner | 36e1207 | 2005-10-30 05:14:02 +0000 | [diff] [blame] | 2 | |
| 3 | ; Make sure we don't get a multiply by 6 in this loop. |
| 4 | |
| 5 | int %foo(int %A, int %B, int %C, int %D) { |
| 6 | entry: |
| 7 | %tmp.5 = setgt int %C, 0 ; <bool> [#uses=1] |
| 8 | %tmp.25 = and int %A, 1 ; <int> [#uses=1] |
| 9 | br label %loopentry.1 |
| 10 | |
| 11 | loopentry.1: ; preds = %loopexit.1, %entry |
| 12 | %indvar20 = phi uint [ 0, %entry ], [ %indvar.next21, %loopexit.1 ] ; <uint> [#uses=2] |
| 13 | %k.1 = phi int [ 0, %entry ], [ %k.1.3, %loopexit.1 ] ; <int> [#uses=2] |
| 14 | br bool %tmp.5, label %no_exit.1.preheader, label %loopexit.1 |
| 15 | |
| 16 | no_exit.1.preheader: ; preds = %loopentry.1 |
| 17 | %i.0.0 = cast uint %indvar20 to int ; <int> [#uses=1] |
| 18 | %tmp.9 = mul int %i.0.0, 6 ; <int> [#uses=1] |
| 19 | br label %no_exit.1.outer |
| 20 | |
| 21 | no_exit.1.outer: ; preds = %cond_true, %no_exit.1.preheader |
| 22 | %k.1.2.ph = phi int [ %k.1, %no_exit.1.preheader ], [ %k.09, %cond_true ] ; <int> [#uses=2] |
| 23 | %j.1.2.ph = phi int [ 0, %no_exit.1.preheader ], [ %inc.1, %cond_true ] ; <int> [#uses=1] |
| 24 | br label %no_exit.1 |
| 25 | |
| 26 | no_exit.1: ; preds = %cond_continue, %no_exit.1.outer |
Reid Spencer | eacb702 | 2006-12-31 06:02:00 +0000 | [diff] [blame] | 27 | %indvar.ui = phi uint [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; <uint> [#uses=2] |
| 28 | %indvar = cast uint %indvar.ui to int ; <int> [#uses=1] |
Chris Lattner | 36e1207 | 2005-10-30 05:14:02 +0000 | [diff] [blame] | 29 | %j.1.2 = add int %indvar, %j.1.2.ph ; <int> [#uses=2] |
| 30 | %tmp.11 = add int %j.1.2, %tmp.9 ; <int> [#uses=1] |
| 31 | %tmp.12 = cast int %tmp.11 to ubyte ; <ubyte> [#uses=1] |
| 32 | %tmp.13 = shl int %D, ubyte %tmp.12 ; <int> [#uses=2] |
| 33 | %tmp.15 = seteq int %tmp.13, %B ; <bool> [#uses=1] |
| 34 | %inc.1 = add int %j.1.2, 1 ; <int> [#uses=3] |
| 35 | br bool %tmp.15, label %cond_true, label %cond_continue |
| 36 | |
| 37 | cond_true: ; preds = %no_exit.1 |
| 38 | %tmp.26 = and int %tmp.25, %tmp.13 ; <int> [#uses=1] |
| 39 | %k.09 = add int %tmp.26, %k.1.2.ph ; <int> [#uses=2] |
| 40 | %tmp.517 = setlt int %inc.1, %C ; <bool> [#uses=1] |
| 41 | br bool %tmp.517, label %no_exit.1.outer, label %loopexit.1 |
| 42 | |
| 43 | cond_continue: ; preds = %no_exit.1 |
| 44 | %tmp.519 = setlt int %inc.1, %C ; <bool> [#uses=1] |
Reid Spencer | eacb702 | 2006-12-31 06:02:00 +0000 | [diff] [blame] | 45 | %indvar.next = add uint %indvar.ui, 1 ; <uint> [#uses=1] |
Chris Lattner | 36e1207 | 2005-10-30 05:14:02 +0000 | [diff] [blame] | 46 | br bool %tmp.519, label %no_exit.1, label %loopexit.1 |
| 47 | |
| 48 | loopexit.1: ; preds = %cond_continue, %cond_true, %loopentry.1 |
| 49 | %k.1.3 = phi int [ %k.1, %loopentry.1 ], [ %k.09, %cond_true ], [ %k.1.2.ph, %cond_continue ] ; <int> [#uses=2] |
| 50 | %indvar.next21 = add uint %indvar20, 1 ; <uint> [#uses=2] |
| 51 | %exitcond = seteq uint %indvar.next21, 4 ; <bool> [#uses=1] |
| 52 | br bool %exitcond, label %loopexit.0, label %loopentry.1 |
| 53 | |
| 54 | loopexit.0: ; preds = %loopexit.1 |
| 55 | ret int %k.1.3 |
| 56 | } |