blob: 0de1cd1bea6de1677157d4e9f3dda429e40dcad1 [file] [log] [blame]
Adam Nemetc4866d22015-06-26 17:25:43 +00001; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s
2
3; For this loop:
4; for (int i = 0; i < n; i++)
5; A[2 * i] = A[2 * i] + B[i];
6;
7; , SCEV is unable to prove that A[2 * i] does not overflow. However,
8; analyzing the IR helps us to conclude it and in turn allow dependence
9; analysis.
10
11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
12
13; CHECK: Memory dependences are safe{{$}}
14
15define void @f(i16* noalias %a,
16 i16* noalias %b, i64 %N) {
17entry:
18 br label %for.body
19
20for.body: ; preds = %for.body, %entry
21 %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
22
23 %mul = mul nuw nsw i64 %ind, 2
24
25 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %mul
26 %loadA = load i16, i16* %arrayidxA, align 2
27
28 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
29 %loadB = load i16, i16* %arrayidxB, align 2
30
31 %add = mul i16 %loadA, %loadB
32
33 store i16 %add, i16* %arrayidxA, align 2
34
35 %inc = add nuw nsw i64 %ind, 1
36 %exitcond = icmp eq i64 %inc, %N
37 br i1 %exitcond, label %for.end, label %for.body
38
39for.end: ; preds = %for.body
40 ret void
41}