• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -loop-accesses -analyze -enable-new-pm=0 < %s | FileCheck %s
2; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output  < %s 2>&1 | FileCheck %s
3
4; Handle memchecks involving loop-invariant addresses:
5;
6; extern int *A, *b;
7; for (i = 0; i < N; ++i) {
8;  A[i] = b;
9; }
10
11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
12
13; CHECK: Memory dependences are safe with run-time checks
14; CHECK: Run-time memory checks:
15; CHECK-NEXT: Check 0:
16; CHECK-NEXT:   Comparing group ({{.*}}):
17; CHECK-NEXT:     %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
18; CHECK-NEXT:   Against group ({{.*}}):
19; CHECK-NEXT:   i32* %b
20
21define void @f(i32* %a, i32* %b) {
22entry:
23  br label %for.body
24
25for.body:                                         ; preds = %for.body, %entry
26  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
27
28  %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
29
30  %loadB = load i32, i32* %b, align 4
31  store i32 %loadB, i32* %arrayidxA, align 4
32
33  %inc = add nuw nsw i64 %ind, 1
34  %exitcond = icmp eq i64 %inc, 20
35  br i1 %exitcond, label %for.end, label %for.body
36
37for.end:                                          ; preds = %for.body
38  ret void
39}
40