1; RUN: opt -S -aa-pipeline=basic-aa -passes=gvn < %s | FileCheck %s 2 3target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" 4target triple = "i386-apple-macosx10.6.0" 5 6; The load and store address in the loop body could alias so the load 7; can't be hoisted above the store and out of the loop. 8 9declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1) 10 11define i32 @foo(i32 %x, i32 %z, i32 %n) { 12entry: 13 %pool = alloca [59 x i32], align 4 14 call void @llvm.memset.p0.i32(ptr align 4 nonnull %pool, i8 0, i32 236, i1 false) 15 %cmp3 = icmp eq i32 %n, 0 16 br i1 %cmp3, label %for.end, label %for.body.lr.ph 17 18for.body.lr.ph: ; preds = %entry 19 %add = add i32 %z, %x 20 %and = and i32 %add, 2147483647 21 %sub = add nsw i32 %and, -2137521902 22 %arrayidx = getelementptr inbounds [59 x i32], ptr %pool, i32 0, i32 %sub 23 %arrayidx1 = getelementptr inbounds [59 x i32], ptr %pool, i32 0, i32 42 24 br label %for.body 25 26for.body: ; preds = %for.body.lr.ph, %for.body 27 %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] 28 store i32 %i.04, ptr %arrayidx, align 4 29 %tmp1 = load i32, ptr %arrayidx1, align 4 30 %inc = add nuw i32 %i.04, 1 31 %exitcond = icmp ne i32 %inc, %n 32 br i1 %exitcond, label %for.body, label %for.end.loopexit 33 34for.end.loopexit: ; preds = %for.body 35 %lcssa = phi i32 [ %tmp1, %for.body ] 36 br label %for.end 37 38for.end: ; preds = %for.end.loopexit, %entry 39 %s = phi i32 [ 0, %entry ], [ %lcssa, %for.end.loopexit ] 40; CHECK: ret i32 %s 41 ret i32 %s 42} 43