1; RUN: opt < %s -basic-aa -loop-interchange -verify-dom-info -verify-loop-info \ 2; RUN: -S -pass-remarks=loop-interchange 2>&1 | FileCheck %s 3 4target triple = "powerpc64le-unknown-linux-gnu" 5@A10 = local_unnamed_addr global [3 x [3 x i32]] zeroinitializer, align 16 6 7;; Test to make sure we can handle zext instructions introduced by 8;; IndVarSimplify. 9;; 10;; for (int i = 0; i < 2; ++i) 11;; for(int j = 0; j < n; ++j) { 12;; A[j][i] = i; 13;; } 14 15; CHECK: Loop interchanged with enclosing loop. 16 17@A11 = local_unnamed_addr global [3 x [3 x i32]] zeroinitializer, align 16 18 19define void @interchange_11(i32 %n) { 20entry: 21 br label %for.cond1.preheader 22 23for.cond.loopexit: ; preds = %for.body4 24 %exitcond28 = icmp ne i64 %indvars.iv.next27, 2 25 br i1 %exitcond28, label %for.cond1.preheader, label %for.cond.cleanup 26 27for.cond1.preheader: ; preds = %for.cond.loopexit, %entry 28 %indvars.iv26 = phi i64 [ 0, %entry ], [ %indvars.iv.next27, %for.cond.loopexit ] 29 %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1 30 br label %for.body4 31 32for.cond.cleanup: ; preds = %for.cond.loopexit 33 ret void 34 35for.body4: ; preds = %for.body4, %for.cond1.preheader 36 %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body4 ] 37; The store below does not appear in the C snippet above. 38; With two stores in the loop there may be WAW dependences, and interchange is illegal. 39; %arrayidx6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv26 40; %tmp = trunc i64 %indvars.iv26 to i32 41; store i32 %tmp, i32* %arrayidx6, align 4 42 %arrayidx10 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv.next27 43 %tmp1 = trunc i64 %indvars.iv to i32 44 store i32 %tmp1, i32* %arrayidx10, align 4 45 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 46 %n.wide = zext i32 %n to i64 47 %exitcond = icmp ne i64 %indvars.iv.next, %n.wide 48 br i1 %exitcond, label %for.body4, label %for.cond.loopexit 49} 50