1*f31811f2SFangrui Song; RUN: opt -basic-aa -loop-versioning -S < %s | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christopher; A very simple case.  After versioning the %loadA and %loadB can't alias with
4cee313d2SEric Christopher; the store.
5cee313d2SEric Christopher;
6cee313d2SEric Christopher; To see it easier what's going on, I expanded every noalias/scope metadata
7cee313d2SEric Christopher; reference below in a comment.  For a scope I use the format scope(domain),
8cee313d2SEric Christopher; e.g. scope 17 in domain 15 is written as 17(15).
9cee313d2SEric Christopher
10cee313d2SEric Christopher; CHECK-LABEL: @f(
11cee313d2SEric Christopher
12cee313d2SEric Christophertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
13cee313d2SEric Christopher
14cee313d2SEric Christopherdefine void @f(i32* %a, i32* %b, i32* %c) {
15cee313d2SEric Christopherentry:
16cee313d2SEric Christopher  br label %for.body
17cee313d2SEric Christopher
18cee313d2SEric Christopher; CHECK: for.body.lver.orig:
19cee313d2SEric Christopher; CHECK: for.body:
20cee313d2SEric Christopherfor.body:                                         ; preds = %for.body, %entry
21cee313d2SEric Christopher  %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
22cee313d2SEric Christopher
23cee313d2SEric Christopher  %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
24cee313d2SEric Christopher; CHECK: %loadA = {{.*}} !alias.scope !0
25cee313d2SEric Christopher; A's scope: !0 -> { 1(2) }
26cee313d2SEric Christopher  %loadA = load i32, i32* %arrayidxA, align 4
27cee313d2SEric Christopher
28cee313d2SEric Christopher  %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind
29cee313d2SEric Christopher; CHECK: %loadB = {{.*}} !alias.scope !3
30cee313d2SEric Christopher; B's scope: !3 -> { 4(2) }
31cee313d2SEric Christopher  %loadB = load i32, i32* %arrayidxB, align 4
32cee313d2SEric Christopher
33cee313d2SEric Christopher  %mulC = mul i32 %loadA, %loadB
34cee313d2SEric Christopher
35cee313d2SEric Christopher  %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind
36cee313d2SEric Christopher; CHECK: store {{.*}} !alias.scope !5, !noalias !7
37cee313d2SEric Christopher; C noalias A and B: !7 -> { 1(2), 4(2) }
38cee313d2SEric Christopher  store i32 %mulC, i32* %arrayidxC, align 4
39cee313d2SEric Christopher
40cee313d2SEric Christopher  %add = add nuw nsw i64 %ind, 1
41cee313d2SEric Christopher  %exitcond = icmp eq i64 %add, 20
42cee313d2SEric Christopher  br i1 %exitcond, label %for.end, label %for.body
43cee313d2SEric Christopher
44cee313d2SEric Christopherfor.end:                                          ; preds = %for.body
45cee313d2SEric Christopher  ret void
46cee313d2SEric Christopher}
47cee313d2SEric Christopher; CHECK: !0 = !{!1}
48cee313d2SEric Christopher; CHECK: !1 = distinct !{!1, !2}
49cee313d2SEric Christopher; CHECK: !2 = distinct !{!2, !"LVerDomain"}
50cee313d2SEric Christopher; CHECK: !3 = !{!4}
51cee313d2SEric Christopher; CHECK: !4 = distinct !{!4, !2}
52cee313d2SEric Christopher; CHECK: !5 = !{!6}
53cee313d2SEric Christopher; CHECK: !6 = distinct !{!6, !2}
54cee313d2SEric Christopher; CHECK: !7 = !{!1, !4}
55