1; RUN: opt < %s -loop-accesses -analyze | FileCheck -check-prefix=OLDPM %s 2; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck -check-prefix=NEWPM %s 3 4; Test to confirm LAA will find store to invariant address. 5; Inner loop has a store to invariant address. 6; 7; for(; i < itr; i++) { 8; for(; j < itr; j++) { 9; var1[i] = var2[j] + var1[i]; 10; } 11; } 12 13; The LAA with the new PM is a loop pass so we go from inner to outer loops. 14 15; OLDPM: for.cond1.preheader: 16; OLDPM: Store to invariant address was not found in loop. 17; OLDPM: for.body3: 18; OLDPM: Store to invariant address was found in loop. 19 20; NEWPM: for.body3: 21; NEWPM: Store to invariant address was found in loop. 22; NEWPM: for.cond1.preheader: 23; NEWPM: Store to invariant address was not found in loop. 24 25define i32 @foo(i32* nocapture %var1, i32* nocapture readonly %var2, i32 %itr) #0 { 26entry: 27 %cmp20 = icmp eq i32 %itr, 0 28 br i1 %cmp20, label %for.end10, label %for.cond1.preheader 29 30for.cond1.preheader: ; preds = %entry, %for.inc8 31 %indvars.iv23 = phi i64 [ %indvars.iv.next24, %for.inc8 ], [ 0, %entry ] 32 %j.022 = phi i32 [ %j.1.lcssa, %for.inc8 ], [ 0, %entry ] 33 %cmp218 = icmp ult i32 %j.022, %itr 34 br i1 %cmp218, label %for.body3.lr.ph, label %for.inc8 35 36for.body3.lr.ph: ; preds = %for.cond1.preheader 37 %arrayidx5 = getelementptr inbounds i32, i32* %var1, i64 %indvars.iv23 38 %0 = zext i32 %j.022 to i64 39 br label %for.body3 40 41for.body3: ; preds = %for.body3, %for.body3.lr.ph 42 %indvars.iv = phi i64 [ %0, %for.body3.lr.ph ], [ %indvars.iv.next, %for.body3 ] 43 %arrayidx = getelementptr inbounds i32, i32* %var2, i64 %indvars.iv 44 %1 = load i32, i32* %arrayidx, align 4 45 %2 = load i32, i32* %arrayidx5, align 4 46 %add = add nsw i32 %2, %1 47 store i32 %add, i32* %arrayidx5, align 4 48 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 49 %lftr.wideiv = trunc i64 %indvars.iv.next to i32 50 %exitcond = icmp eq i32 %lftr.wideiv, %itr 51 br i1 %exitcond, label %for.inc8, label %for.body3 52 53for.inc8: ; preds = %for.body3, %for.cond1.preheader 54 %j.1.lcssa = phi i32 [ %j.022, %for.cond1.preheader ], [ %itr, %for.body3 ] 55 %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1 56 %lftr.wideiv25 = trunc i64 %indvars.iv.next24 to i32 57 %exitcond26 = icmp eq i32 %lftr.wideiv25, %itr 58 br i1 %exitcond26, label %for.end10, label %for.cond1.preheader 59 60for.end10: ; preds = %for.inc8, %entry 61 ret i32 undef 62} 63 64