Sebastian Pop | bf6e1c2 | 2018-03-06 21:55:59 +0000 | [diff] [blame] | 1 | ; REQUIRES: asserts |
| 2 | ; RUN: opt < %s -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s |
David Green | 907b60f | 2017-10-21 13:58:37 +0000 | [diff] [blame] | 3 | ;; Checks the order of the inner phi nodes does not cause havoc. |
| 4 | ;; The inner loop has a reduction into c. The IV is not the first phi. |
| 5 | |
Sebastian Pop | bf6e1c2 | 2018-03-06 21:55:59 +0000 | [diff] [blame] | 6 | ; CHECK: Not interchanging loops. Cannot prove legality. |
| 7 | |
David Green | 907b60f | 2017-10-21 13:58:37 +0000 | [diff] [blame] | 8 | target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 9 | target triple = "armv8--linux-gnueabihf" |
| 10 | |
| 11 | ; Function Attrs: norecurse nounwind |
| 12 | define void @test(i32 %T, [90 x i32]* noalias nocapture %C, i16* noalias nocapture readonly %A, i16* noalias nocapture readonly %B) local_unnamed_addr #0 { |
| 13 | entry: |
| 14 | %cmp45 = icmp sgt i32 %T, 0 |
| 15 | br i1 %cmp45, label %for.body3.lr.ph.preheader, label %for.end21 |
| 16 | |
| 17 | for.body3.lr.ph.preheader: ; preds = %entry |
| 18 | br label %for.body3.lr.ph |
| 19 | |
| 20 | for.body3.lr.ph: ; preds = %for.body3.lr.ph.preheader, %for.inc19 |
| 21 | %i.046 = phi i32 [ %inc20, %for.inc19 ], [ 0, %for.body3.lr.ph.preheader ] |
| 22 | %mul = mul nsw i32 %i.046, %T |
| 23 | br label %for.body6.lr.ph |
| 24 | |
| 25 | for.body6.lr.ph: ; preds = %for.inc16, %for.body3.lr.ph |
| 26 | %j.043 = phi i32 [ 0, %for.body3.lr.ph ], [ %inc17, %for.inc16 ] |
| 27 | %arrayidx14 = getelementptr inbounds [90 x i32], [90 x i32]* %C, i32 %i.046, i32 %j.043 |
| 28 | %arrayidx14.promoted = load i32, i32* %arrayidx14, align 4 |
| 29 | br label %for.body6 |
| 30 | |
| 31 | for.body6: ; preds = %for.body6, %for.body6.lr.ph |
| 32 | %add1541 = phi i32 [ %arrayidx14.promoted, %for.body6.lr.ph ], [ %add15, %for.body6 ] |
| 33 | %k.040 = phi i32 [ 0, %for.body6.lr.ph ], [ %inc, %for.body6 ] |
| 34 | %add = add nsw i32 %k.040, %mul |
| 35 | %arrayidx = getelementptr inbounds i16, i16* %A, i32 %add |
| 36 | %0 = load i16, i16* %arrayidx, align 2 |
| 37 | %conv = sext i16 %0 to i32 |
| 38 | %mul7 = mul nsw i32 %k.040, %T |
| 39 | %add8 = add nsw i32 %mul7, %j.043 |
| 40 | %arrayidx9 = getelementptr inbounds i16, i16* %B, i32 %add8 |
| 41 | %1 = load i16, i16* %arrayidx9, align 2 |
| 42 | %conv10 = sext i16 %1 to i32 |
| 43 | %mul11 = mul nsw i32 %conv10, %conv |
| 44 | %add15 = add nsw i32 %mul11, %add1541 |
| 45 | %inc = add nuw nsw i32 %k.040, 1 |
| 46 | %exitcond = icmp eq i32 %inc, %T |
| 47 | br i1 %exitcond, label %for.inc16, label %for.body6 |
| 48 | |
| 49 | for.inc16: ; preds = %for.body6 |
| 50 | %add15.lcssa = phi i32 [ %add15, %for.body6 ] |
| 51 | store i32 %add15.lcssa, i32* %arrayidx14, align 4 |
| 52 | %inc17 = add nuw nsw i32 %j.043, 1 |
| 53 | %exitcond47 = icmp eq i32 %inc17, %T |
| 54 | br i1 %exitcond47, label %for.inc19, label %for.body6.lr.ph |
| 55 | |
| 56 | for.inc19: ; preds = %for.inc16 |
| 57 | %inc20 = add nuw nsw i32 %i.046, 1 |
| 58 | %exitcond48 = icmp eq i32 %inc20, %T |
| 59 | br i1 %exitcond48, label %for.end21.loopexit, label %for.body3.lr.ph |
| 60 | |
| 61 | for.end21.loopexit: ; preds = %for.inc19 |
| 62 | br label %for.end21 |
| 63 | |
| 64 | for.end21: ; preds = %for.end21.loopexit, %entry |
| 65 | ret void |
| 66 | } |