1 ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
3 target datalayout = "e-m:o-p:64:64-f64:32:64-f80:128-n8:16:32-S128"
4 target triple = "x86_64-apple-macosx10.6.0"
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.
9 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1)
11 define i64 @foo(i64 %x, i64 %z, i64 %n) {
13 %pool = alloca [59 x i64], align 4
14 %tmp = bitcast [59 x i64]* %pool to i8*
15 call void @llvm.memset.p0i8.i64(i8* nonnull %tmp, i8 0, i64 236, i32 4, i1 false)
16 %cmp3 = icmp eq i64 %n, 0
17 br i1 %cmp3, label %for.end, label %for.body.lr.ph
19 for.body.lr.ph: ; preds = %entry
21 %and = and i64 %add, 9223372036854775807
22 %sub = add nsw i64 %and, -9223372036844814062
23 %arrayidx = getelementptr inbounds [59 x i64], [59 x i64]* %pool, i64 0, i64 %sub
24 %arrayidx1 = getelementptr inbounds [59 x i64], [59 x i64]* %pool, i64 0, i64 42
27 for.body: ; preds = %for.body.lr.ph, %for.body
28 %i.04 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
29 store i64 %i.04, i64* %arrayidx, align 4
30 %tmp1 = load i64, i64* %arrayidx1, align 4
31 %inc = add nuw i64 %i.04, 1
32 %exitcond = icmp ne i64 %inc, %n
33 br i1 %exitcond, label %for.body, label %for.end.loopexit
35 for.end.loopexit: ; preds = %for.body
36 %lcssa = phi i64 [ %tmp1, %for.body ]
39 for.end: ; preds = %for.end.loopexit, %entry
40 %s = phi i64 [ 0, %entry ], [ %lcssa, %for.end.loopexit ]