blob: 0fa17b68a9d1bd1c83fc51cd7e279504b783bdf8 [file] [log] [blame]
Gerolf Hoflehner9e2afa82016-10-22 02:41:39 +00001; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
Hal Finkel4f238142019-01-02 16:28:09 +00002; RUN: opt -S -basicaa -gvn -basicaa-force-at-least-64b=0 < %s | FileCheck %s
Gerolf Hoflehner9e2afa82016-10-22 02:41:39 +00003
4target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
5target triple = "i386-apple-macosx10.6.0"
6
7; The load and store address in the loop body could alias so the load
8; can't be hoisted above the store and out of the loop.
9
Daniel Neilson1e687242018-01-19 17:13:12 +000010declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)
Gerolf Hoflehner9e2afa82016-10-22 02:41:39 +000011
12define i32 @foo(i32 %x, i32 %z, i32 %n) {
13entry:
14 %pool = alloca [59 x i32], align 4
15 %tmp = bitcast [59 x i32]* %pool to i8*
Daniel Neilson1e687242018-01-19 17:13:12 +000016 call void @llvm.memset.p0i8.i32(i8* align 4 nonnull %tmp, i8 0, i32 236, i1 false)
Gerolf Hoflehner9e2afa82016-10-22 02:41:39 +000017 %cmp3 = icmp eq i32 %n, 0
18 br i1 %cmp3, label %for.end, label %for.body.lr.ph
19
20for.body.lr.ph: ; preds = %entry
21 %add = add i32 %z, %x
22 %and = and i32 %add, 2147483647
23 %sub = add nsw i32 %and, -2137521902
24 %arrayidx = getelementptr inbounds [59 x i32], [59 x i32]* %pool, i32 0, i32 %sub
25 %arrayidx1 = getelementptr inbounds [59 x i32], [59 x i32]* %pool, i32 0, i32 42
26 br label %for.body
27
28for.body: ; preds = %for.body.lr.ph, %for.body
29 %i.04 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
30 store i32 %i.04, i32* %arrayidx, align 4
31 %tmp1 = load i32, i32* %arrayidx1, align 4
32 %inc = add nuw i32 %i.04, 1
33 %exitcond = icmp ne i32 %inc, %n
34 br i1 %exitcond, label %for.body, label %for.end.loopexit
35
36for.end.loopexit: ; preds = %for.body
37 %lcssa = phi i32 [ %tmp1, %for.body ]
38 br label %for.end
39
40for.end: ; preds = %for.end.loopexit, %entry
41 %s = phi i32 [ 0, %entry ], [ %lcssa, %for.end.loopexit ]
42; CHECK: ret i32 %s
43 ret i32 %s
44}