Florian Hahn | c6296fe | 2018-02-14 13:13:15 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -loop-interchange -verify-dom-info -S | FileCheck %s |
David Green | 907b60f | 2017-10-21 13:58:37 +0000 | [diff] [blame] | 2 | ;; Checks the order of the inner phi nodes does not cause havoc. |
| 3 | ;; The inner loop has a reduction into c. The IV is not the first phi. |
| 4 | |
| 5 | target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 6 | target triple = "armv8--linux-gnueabihf" |
| 7 | |
| 8 | ; Function Attrs: norecurse nounwind |
| 9 | 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 { |
| 10 | entry: |
| 11 | %cmp45 = icmp sgt i32 %T, 0 |
| 12 | br i1 %cmp45, label %for.body3.lr.ph.preheader, label %for.end21 |
| 13 | |
| 14 | for.body3.lr.ph.preheader: ; preds = %entry |
| 15 | br label %for.body3.lr.ph |
| 16 | |
| 17 | for.body3.lr.ph: ; preds = %for.body3.lr.ph.preheader, %for.inc19 |
| 18 | %i.046 = phi i32 [ %inc20, %for.inc19 ], [ 0, %for.body3.lr.ph.preheader ] |
| 19 | %mul = mul nsw i32 %i.046, %T |
| 20 | br label %for.body6.lr.ph |
| 21 | |
| 22 | for.body6.lr.ph: ; preds = %for.inc16, %for.body3.lr.ph |
| 23 | %j.043 = phi i32 [ 0, %for.body3.lr.ph ], [ %inc17, %for.inc16 ] |
| 24 | %arrayidx14 = getelementptr inbounds [90 x i32], [90 x i32]* %C, i32 %i.046, i32 %j.043 |
| 25 | %arrayidx14.promoted = load i32, i32* %arrayidx14, align 4 |
| 26 | br label %for.body6 |
| 27 | |
| 28 | for.body6: ; preds = %for.body6, %for.body6.lr.ph |
| 29 | %add1541 = phi i32 [ %arrayidx14.promoted, %for.body6.lr.ph ], [ %add15, %for.body6 ] |
| 30 | %k.040 = phi i32 [ 0, %for.body6.lr.ph ], [ %inc, %for.body6 ] |
| 31 | %add = add nsw i32 %k.040, %mul |
| 32 | %arrayidx = getelementptr inbounds i16, i16* %A, i32 %add |
| 33 | %0 = load i16, i16* %arrayidx, align 2 |
| 34 | %conv = sext i16 %0 to i32 |
| 35 | %mul7 = mul nsw i32 %k.040, %T |
| 36 | %add8 = add nsw i32 %mul7, %j.043 |
| 37 | %arrayidx9 = getelementptr inbounds i16, i16* %B, i32 %add8 |
| 38 | %1 = load i16, i16* %arrayidx9, align 2 |
| 39 | %conv10 = sext i16 %1 to i32 |
| 40 | %mul11 = mul nsw i32 %conv10, %conv |
| 41 | %add15 = add nsw i32 %mul11, %add1541 |
| 42 | %inc = add nuw nsw i32 %k.040, 1 |
| 43 | %exitcond = icmp eq i32 %inc, %T |
| 44 | br i1 %exitcond, label %for.inc16, label %for.body6 |
| 45 | |
| 46 | for.inc16: ; preds = %for.body6 |
| 47 | %add15.lcssa = phi i32 [ %add15, %for.body6 ] |
| 48 | store i32 %add15.lcssa, i32* %arrayidx14, align 4 |
| 49 | %inc17 = add nuw nsw i32 %j.043, 1 |
| 50 | %exitcond47 = icmp eq i32 %inc17, %T |
| 51 | br i1 %exitcond47, label %for.inc19, label %for.body6.lr.ph |
| 52 | |
| 53 | for.inc19: ; preds = %for.inc16 |
| 54 | %inc20 = add nuw nsw i32 %i.046, 1 |
| 55 | %exitcond48 = icmp eq i32 %inc20, %T |
| 56 | br i1 %exitcond48, label %for.end21.loopexit, label %for.body3.lr.ph |
| 57 | |
| 58 | for.end21.loopexit: ; preds = %for.inc19 |
| 59 | br label %for.end21 |
| 60 | |
| 61 | for.end21: ; preds = %for.end21.loopexit, %entry |
| 62 | ret void |
| 63 | } |
| 64 | |
| 65 | |
| 66 | ; CHECK-LABEL: test |
| 67 | ; CHECK: entry: |
| 68 | ; CHECK: br i1 %cmp45, label %for.body6.preheader, label %for.end21 |
| 69 | ; CHECK: for.body3.lr.ph.preheader: |
| 70 | ; CHECK: br label %for.body3.lr.ph |
| 71 | ; CHECK: for.body3.lr.ph: |
| 72 | ; CHECK: br label %for.body6.lr.ph.preheader |
| 73 | ; CHECK: for.body6.lr.ph.preheader: |
| 74 | ; CHECK: br label %for.body6.lr.ph |
| 75 | ; CHECK: for.body6.lr.ph: |
| 76 | ; CHECK: br label %for.body6.split1 |
| 77 | ; CHECK: for.body6.preheader: |
| 78 | ; CHECK: br label %for.body6 |
| 79 | ; CHECK: for.body6: |
| 80 | ; CHECK: br label %for.body3.lr.ph.preheader |
| 81 | ; CHECK: for.body6.split1: |
| 82 | ; CHECK: br label %for.inc16 |
| 83 | ; CHECK: for.body6.split: |
| 84 | ; CHECK: add nuw nsw i32 %k.040, 1 |
| 85 | ; CHECK: br i1 %exitcond, label %for.end21.loopexit, label %for.body6 |
| 86 | ; CHECK: for.inc16: |
| 87 | ; CHECK: br i1 %exitcond47, label %for.inc19, label %for.body6.lr.ph |
| 88 | ; CHECK: for.inc19: |
| 89 | ; CHECK: br i1 %exitcond48, label %for.body6.split, label %for.body3.lr.ph |
| 90 | ; CHECK: for.end21: |