1 ; RUN: opt -S -passes=loop-rotate -verify-memoryssa < %s | FileCheck %s
2 ; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(loop-rotate)' < %s | FileCheck %s
3 ; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(loop-rotate)' -verify-memoryssa < %s | FileCheck %s
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
10 define void @test_02(ptr nocapture %_pA) nounwind ssp {
11 ; CHECK-LABEL: @test_02(
13 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
14 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !2
16 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5)
17 ; CHECK: store i32 0, ptr %array, align 16, !noalias !5
18 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !7)
19 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !7
23 %array = alloca [20 x i32], align 16
26 for.cond: ; preds = %for.body, %entry
27 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
28 tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
29 store i32 42, ptr %_pA, align 16, !alias.scope !2
30 %cmp = icmp slt i32 %i.0, 100
31 br i1 %cmp, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 store i32 0, ptr %array, align 16, !noalias !2
35 %inc = add nsw i32 %i.0, 1
38 for.end: ; preds = %for.cond
39 %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
40 call void @g(ptr %arrayidx.lcssa) nounwind
44 define void @test_03(ptr nocapture %_pA) nounwind ssp {
45 ; CHECK-LABEL: @test_03(
48 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5)
49 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !5
50 ; CHECK: store i32 0, ptr %array, align 16, !noalias !5
54 %array = alloca [20 x i32], align 16
57 for.cond: ; preds = %for.body, %entry
58 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
59 %cmp = icmp slt i32 %i.0, 100
60 br i1 %cmp, label %for.body, label %for.end
62 for.body: ; preds = %for.cond
63 tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
64 store i32 42, ptr %_pA, align 16, !alias.scope !2
65 store i32 0, ptr %array, align 16, !noalias !2
66 %inc = add nsw i32 %i.0, 1
69 for.end: ; preds = %for.cond
70 %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
71 call void @g(ptr %arrayidx.lcssa) nounwind
75 define void @test_04(ptr nocapture %_pA) nounwind ssp {
76 ; CHECK-LABEL: @test_04(
78 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !9)
79 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !9
81 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5)
82 ; CHECK: store i32 0, ptr %array, align 16, !noalias !5
83 ; CHECK: store i32 43, ptr %_pA, align 16, !alias.scope !5
84 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !11)
85 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !11
88 %array = alloca [20 x i32], align 16
91 for.cond: ; preds = %for.body, %entry
92 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
93 tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
94 store i32 42, ptr %_pA, align 16, !alias.scope !2
95 %cmp = icmp slt i32 %i.0, 100
96 br i1 %cmp, label %for.body, label %for.end
98 for.body: ; preds = %for.cond
99 store i32 0, ptr %array, align 16, !noalias !2
100 store i32 43, ptr %_pA, align 16, !alias.scope !2
101 %inc = add nsw i32 %i.0, 1
104 for.end: ; preds = %for.cond
105 %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
106 call void @g(ptr %arrayidx.lcssa) nounwind
110 define void @test_05(ptr nocapture %_pA) nounwind ssp {
111 ; CHECK-LABEL: @test_05(
113 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !13)
114 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !13
116 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !5)
117 ; CHECK: store i32 0, ptr %array, align 16, !noalias !5
118 ; CHECK: store i32 43, ptr %_pA, align 16, !alias.scope !5
119 ; CHECK: tail call void @llvm.experimental.noalias.scope.decl(metadata !15)
120 ; CHECK: store i32 42, ptr %_pA, align 16, !alias.scope !15
122 ; CHECK: store i32 44, ptr %_pA, align 16, !alias.scope !5
125 %array = alloca [20 x i32], align 16
128 for.cond: ; preds = %for.body, %entry
129 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
130 tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
131 store i32 42, ptr %_pA, align 16, !alias.scope !2
132 %cmp = icmp slt i32 %i.0, 100
133 br i1 %cmp, label %for.body, label %for.end
135 for.body: ; preds = %for.cond
136 store i32 0, ptr %array, align 16, !noalias !2
137 store i32 43, ptr %_pA, align 16, !alias.scope !2
138 %inc = add nsw i32 %i.0, 1
141 for.end: ; preds = %for.cond
142 %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
143 store i32 44, ptr %_pA, align 16, !alias.scope !2
144 call void @g(ptr %arrayidx.lcssa) nounwind
148 ; Function Attrs: inaccessiblememonly nounwind
149 declare void @llvm.experimental.noalias.scope.decl(metadata) #1
151 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
152 attributes #1 = { inaccessiblememonly nounwind }
153 attributes #2 = { nounwind readnone speculatable }
155 !llvm.module.flags = !{!0}
158 !0 = !{i32 1, !"wchar_size", i32 4}
161 !3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA"}
162 !4 = distinct !{!4, !"test_loop_rotate_XX"}
164 ; CHECK: !0 = !{i32 1, !"wchar_size", i32 4}
165 ; CHECK: !1 = !{!"clang"}
167 ; CHECK: !3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA:pre.rot"}
168 ; CHECK: !4 = distinct !{!4, !"test_loop_rotate_XX"}
170 ; CHECK: !6 = distinct !{!6, !4, !"test_loop_rotate_XX: pA"}
172 ; CHECK: !8 = distinct !{!8, !4, !"test_loop_rotate_XX: pA:h.rot"}
174 ; CHECK: !10 = distinct !{!10, !4, !"test_loop_rotate_XX: pA:pre.rot"}
175 ; CHECK: !11 = !{!12}
176 ; CHECK: !12 = distinct !{!12, !4, !"test_loop_rotate_XX: pA:h.rot"}
177 ; CHECK: !13 = !{!14}
178 ; CHECK: !14 = distinct !{!14, !4, !"test_loop_rotate_XX: pA:pre.rot"}
179 ; CHECK: !15 = !{!16}
180 ; CHECK: !16 = distinct !{!16, !4, !"test_loop_rotate_XX: pA:h.rot"}