Arthur Eubanks | 9db0c57 | 2020-09-15 21:10:22 -0700 | [diff] [blame] | 1 | ; RUN: opt < %s -analyze -enable-new-pm=0 -delinearize | FileCheck %s |
| 2 | ; RUN: opt < %s -passes='print<delinearization>' -disable-output 2>&1 | FileCheck %s |
Sebastian Pop | c62c679 | 2013-11-12 22:47:20 +0000 | [diff] [blame] | 3 | ; |
| 4 | ; void foo(long n, long m, long o, int A[n][m][o]) { |
| 5 | ; for (long i = 0; i < n; i++) |
| 6 | ; for (long j = 0; j < m; j++) |
| 7 | ; for (long k = 0; k < o; k++) |
| 8 | ; A[2*i+3][3*j-4][5*k+7] = 1; |
| 9 | ; } |
| 10 | |
| 11 | ; AddRec: {{{(28 + (4 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j>,+,20}<%for.k> |
| 12 | ; CHECK: Base offset: %A |
Mehdi Amini | 46a4355 | 2015-03-04 18:43:29 +0000 | [diff] [blame] | 13 | ; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 4 bytes. |
Tim Shen | a064622 | 2018-07-13 23:58:46 +0000 | [diff] [blame] | 14 | ; CHECK: ArrayRef[{3,+,2}<nw><%for.i>][{-4,+,3}<nw><%for.j>][{7,+,5}<nw><%for.k>] |
Sebastian Pop | c62c679 | 2013-11-12 22:47:20 +0000 | [diff] [blame] | 15 | |
Sebastian Pop | c62c679 | 2013-11-12 22:47:20 +0000 | [diff] [blame] | 16 | define void @foo(i64 %n, i64 %m, i64 %o, i32* nocapture %A) #0 { |
| 17 | entry: |
| 18 | %cmp32 = icmp sgt i64 %n, 0 |
| 19 | br i1 %cmp32, label %for.cond1.preheader.lr.ph, label %for.end17 |
| 20 | |
| 21 | for.cond1.preheader.lr.ph: ; preds = %entry |
| 22 | %cmp230 = icmp sgt i64 %m, 0 |
| 23 | %cmp528 = icmp sgt i64 %o, 0 |
| 24 | br i1 %cmp230, label %for.i, label %for.end17 |
| 25 | |
| 26 | for.inc15.us: ; preds = %for.inc12.us.us, %for.i |
| 27 | %inc16.us = add nsw i64 %i.033.us, 1 |
| 28 | %exitcond55 = icmp eq i64 %inc16.us, %n |
| 29 | br i1 %exitcond55, label %for.end17, label %for.i |
| 30 | |
| 31 | for.i: ; preds = %for.cond1.preheader.lr.ph, %for.inc15.us |
| 32 | %i.033.us = phi i64 [ %inc16.us, %for.inc15.us ], [ 0, %for.cond1.preheader.lr.ph ] |
| 33 | %mul8.us = shl i64 %i.033.us, 1 |
| 34 | %add9.us = add nsw i64 %mul8.us, 3 |
| 35 | %0 = mul i64 %add9.us, %m |
| 36 | %sub.us = add i64 %0, -4 |
| 37 | br i1 %cmp528, label %for.j, label %for.inc15.us |
| 38 | |
| 39 | for.inc12.us.us: ; preds = %for.k |
| 40 | %inc13.us.us = add nsw i64 %j.031.us.us, 1 |
| 41 | %exitcond54 = icmp eq i64 %inc13.us.us, %m |
| 42 | br i1 %exitcond54, label %for.inc15.us, label %for.j |
| 43 | |
| 44 | for.j: ; preds = %for.i, %for.inc12.us.us |
| 45 | %j.031.us.us = phi i64 [ %inc13.us.us, %for.inc12.us.us ], [ 0, %for.i ] |
| 46 | %mul7.us.us = mul nsw i64 %j.031.us.us, 3 |
| 47 | %tmp.us.us = add i64 %sub.us, %mul7.us.us |
| 48 | %tmp27.us.us = mul i64 %tmp.us.us, %o |
| 49 | br label %for.k |
| 50 | |
| 51 | for.k: ; preds = %for.k, %for.j |
| 52 | %k.029.us.us = phi i64 [ 0, %for.j ], [ %inc.us.us, %for.k ] |
| 53 | %mul.us.us = mul nsw i64 %k.029.us.us, 5 |
| 54 | %arrayidx.sum.us.us = add i64 %mul.us.us, 7 |
| 55 | %arrayidx10.sum.us.us = add i64 %arrayidx.sum.us.us, %tmp27.us.us |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 56 | %arrayidx11.us.us = getelementptr inbounds i32, i32* %A, i64 %arrayidx10.sum.us.us |
Sebastian Pop | c62c679 | 2013-11-12 22:47:20 +0000 | [diff] [blame] | 57 | store i32 1, i32* %arrayidx11.us.us, align 4 |
| 58 | %inc.us.us = add nsw i64 %k.029.us.us, 1 |
| 59 | %exitcond = icmp eq i64 %inc.us.us, %o |
| 60 | br i1 %exitcond, label %for.inc12.us.us, label %for.k |
| 61 | |
| 62 | for.end17: ; preds = %for.inc15.us, %for.cond1.preheader.lr.ph, %entry |
| 63 | ret void |
| 64 | } |