1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -loop-unroll -unroll-count=4 < %s | FileCheck %s
3
4define void @test_inside(i32* %addr1, i32* %addr2) {
5; CHECK-LABEL: @test_inside(
6; CHECK-NEXT:  start:
7; CHECK-NEXT:    br label [[BODY:%.*]]
8; CHECK:       body:
9; CHECK-NEXT:    call void @llvm.experimental.noalias.scope.decl(metadata !0)
10; CHECK-NEXT:    [[X:%.*]] = load i32, i32* [[ADDR1:%.*]], align 4, !alias.scope !0
11; CHECK-NEXT:    store i32 [[X]], i32* [[ADDR2:%.*]], align 4, !noalias !0
12; CHECK-NEXT:    [[ADDR1I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR1]], i32 1
13; CHECK-NEXT:    [[ADDR2I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR2]], i32 1
14; CHECK-NEXT:    call void @llvm.experimental.noalias.scope.decl(metadata !3)
15; CHECK-NEXT:    [[X_1:%.*]] = load i32, i32* [[ADDR1I_1]], align 4, !alias.scope !3
16; CHECK-NEXT:    store i32 [[X_1]], i32* [[ADDR2I_1]], align 4, !noalias !3
17; CHECK-NEXT:    call void @llvm.experimental.noalias.scope.decl(metadata !5)
18; CHECK-NEXT:    [[X_2:%.*]] = load i32, i32* [[ADDR1]], align 4, !alias.scope !5
19; CHECK-NEXT:    store i32 [[X_2]], i32* [[ADDR2]], align 4, !noalias !5
20; CHECK-NEXT:    [[ADDR1I_3:%.*]] = getelementptr inbounds i32, i32* [[ADDR1]], i32 1
21; CHECK-NEXT:    [[ADDR2I_3:%.*]] = getelementptr inbounds i32, i32* [[ADDR2]], i32 1
22; CHECK-NEXT:    call void @llvm.experimental.noalias.scope.decl(metadata !7)
23; CHECK-NEXT:    [[X_3:%.*]] = load i32, i32* [[ADDR1I_3]], align 4, !alias.scope !7
24; CHECK-NEXT:    store i32 [[X_3]], i32* [[ADDR2I_3]], align 4, !noalias !7
25; CHECK-NEXT:    ret void
26;
27start:
28  br label %body
29
30body:
31  %i = phi i32 [ 0, %start ], [ %i2, %body ]
32  %j = and i32 %i, 1
33  %addr1i = getelementptr inbounds i32, i32* %addr1, i32 %j
34  %addr2i = getelementptr inbounds i32, i32* %addr2, i32 %j
35
36  call void @llvm.experimental.noalias.scope.decl(metadata !2)
37  %x = load i32, i32* %addr1i, !alias.scope !2
38  store i32 %x, i32* %addr2i, !noalias !2
39
40  %i2 = add i32 %i, 1
41  %cmp = icmp slt i32 %i2, 4
42  br i1 %cmp, label %body, label %end
43
44end:
45  ret void
46}
47
48define void @test_outside(i32* %addr1, i32* %addr2) {
49; CHECK-LABEL: @test_outside(
50; CHECK-NEXT:  start:
51; CHECK-NEXT:    call void @llvm.experimental.noalias.scope.decl(metadata !0)
52; CHECK-NEXT:    br label [[BODY:%.*]]
53; CHECK:       body:
54; CHECK-NEXT:    [[X:%.*]] = load i32, i32* [[ADDR1:%.*]], align 4, !alias.scope !0
55; CHECK-NEXT:    store i32 [[X]], i32* [[ADDR2:%.*]], align 4, !noalias !0
56; CHECK-NEXT:    [[ADDR1I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR1]], i32 1
57; CHECK-NEXT:    [[ADDR2I_1:%.*]] = getelementptr inbounds i32, i32* [[ADDR2]], i32 1
58; CHECK-NEXT:    [[X_1:%.*]] = load i32, i32* [[ADDR1I_1]], align 4, !alias.scope !0
59; CHECK-NEXT:    store i32 [[X_1]], i32* [[ADDR2I_1]], align 4, !noalias !0
60; CHECK-NEXT:    [[X_2:%.*]] = load i32, i32* [[ADDR1]], align 4, !alias.scope !0
61; CHECK-NEXT:    store i32 [[X_2]], i32* [[ADDR2]], align 4, !noalias !0
62; CHECK-NEXT:    [[ADDR1I_3:%.*]] = getelementptr inbounds i32, i32* [[ADDR1]], i32 1
63; CHECK-NEXT:    [[ADDR2I_3:%.*]] = getelementptr inbounds i32, i32* [[ADDR2]], i32 1
64; CHECK-NEXT:    [[X_3:%.*]] = load i32, i32* [[ADDR1I_3]], align 4, !alias.scope !0
65; CHECK-NEXT:    store i32 [[X_3]], i32* [[ADDR2I_3]], align 4, !noalias !0
66; CHECK-NEXT:    ret void
67;
68start:
69  call void @llvm.experimental.noalias.scope.decl(metadata !2)
70  br label %body
71
72body:
73  %i = phi i32 [ 0, %start ], [ %i2, %body ]
74  %j = and i32 %i, 1
75  %addr1i = getelementptr inbounds i32, i32* %addr1, i32 %j
76  %addr2i = getelementptr inbounds i32, i32* %addr2, i32 %j
77
78  %x = load i32, i32* %addr1i, !alias.scope !2
79  store i32 %x, i32* %addr2i, !noalias !2
80
81  %i2 = add i32 %i, 1
82  %cmp = icmp slt i32 %i2, 4
83  br i1 %cmp, label %body, label %end
84
85end:
86  ret void
87}
88
89declare void @llvm.experimental.noalias.scope.decl(metadata)
90
91!0 = distinct !{!0}
92!1 = distinct !{!1, !0}
93!2 = !{!1}
94
95; CHECK: !0 = !{!1}
96; CHECK: !1 = distinct !{!1, !2}
97; CHECK: !2 = distinct !{!2}
98; CHECK: !3 = !{!4}
99; CHECK: !4 = distinct !{!4, !2, !"It1"}
100; CHECK: !5 = !{!6}
101; CHECK: !6 = distinct !{!6, !2, !"It2"}
102; CHECK: !7 = !{!8}
103; CHECK: !8 = distinct !{!8, !2, !"It3"}
104