xref: /llvm-project/llvm/test/Transforms/LoopRotate/noalias.ll (revision e390c229a438ed1eb3396df8fbeeda89c49474e6)
1; RUN: opt -S -passes=loop-rotate -verify-memoryssa < %s | FileCheck %s
2; RUN: opt -S -passes='require<target-ir>,require<assumptions>,loop(loop-rotate)' < %s | FileCheck %s
3; RUN: opt -S -passes='require<target-ir>,require<assumptions>,loop(loop-rotate)' -verify-memoryssa  < %s | FileCheck %s
4
5target 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"
6target triple = "x86_64-unknown-linux-gnu"
7
8declare void @g(ptr)
9
10define void @test_02(ptr nocapture %_pA) nounwind ssp {
11; CHECK-LABEL: @test_02(
12; CHECK: entry:
13; CHECK:   tail call void @llvm.experimental.noalias.scope.decl(metadata !2)
14; CHECK:   store i32 42, ptr %_pA, align 16, !alias.scope !2
15; CHECK: for.body:
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
20; CHECK: for.end:
21
22entry:
23  %array = alloca [20 x i32], align 16
24  br label %for.cond
25
26for.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
32
33for.body:                                         ; preds = %for.cond
34  store i32 0, ptr %array, align 16, !noalias !2
35  %inc = add nsw i32 %i.0, 1
36  br label %for.cond
37
38for.end:                                          ; preds = %for.cond
39  %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
40  call void @g(ptr %arrayidx.lcssa) nounwind
41  ret void
42}
43
44define void @test_03(ptr nocapture %_pA) nounwind ssp {
45; CHECK-LABEL: @test_03(
46; CHECK: entry:
47; CHECK: for.body:
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
51; CHECK: for.end:
52
53entry:
54  %array = alloca [20 x i32], align 16
55  br label %for.cond
56
57for.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
61
62for.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
67  br label %for.cond
68
69for.end:                                          ; preds = %for.cond
70  %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
71  call void @g(ptr %arrayidx.lcssa) nounwind
72  ret void
73}
74
75define void @test_04(ptr nocapture %_pA) nounwind ssp {
76; CHECK-LABEL: @test_04(
77; CHECK: entry:
78; CHECK:   tail call void @llvm.experimental.noalias.scope.decl(metadata !9)
79; CHECK:   store i32 42, ptr %_pA, align 16, !alias.scope !9
80; CHECK: for.body:
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
86; CHECK: for.end:
87entry:
88  %array = alloca [20 x i32], align 16
89  br label %for.cond
90
91for.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
97
98for.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
102  br label %for.cond
103
104for.end:                                          ; preds = %for.cond
105  %arrayidx.lcssa = phi ptr [ %array, %for.cond ]
106  call void @g(ptr %arrayidx.lcssa) nounwind
107  ret void
108}
109
110define void @test_05(ptr nocapture %_pA) nounwind ssp {
111; CHECK-LABEL: @test_05(
112; CHECK: entry:
113; CHECK:   tail call void @llvm.experimental.noalias.scope.decl(metadata !13)
114; CHECK:   store i32 42, ptr %_pA, align 16, !alias.scope !13
115; CHECK: for.body:
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
121; CHECK: for.end:
122; CHECK:   store i32 44, ptr %_pA, align 16, !alias.scope !5
123
124entry:
125  %array = alloca [20 x i32], align 16
126  br label %for.cond
127
128for.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
134
135for.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
139  br label %for.cond
140
141for.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
145  ret void
146}
147
148; Function Attrs: inaccessiblememonly nounwind
149declare void @llvm.experimental.noalias.scope.decl(metadata) #1
150
151attributes #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" }
152attributes #1 = { inaccessiblememonly nounwind }
153attributes #2 = { nounwind readnone speculatable }
154
155!llvm.module.flags = !{!0}
156!llvm.ident = !{!1}
157
158!0 = !{i32 1, !"wchar_size", i32 4}
159!1 = !{!"clang"}
160!2 = !{!3}
161!3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA"}
162!4 = distinct !{!4, !"test_loop_rotate_XX"}
163
164; CHECK: !0 = !{i32 1, !"wchar_size", i32 4}
165; CHECK: !1 = !{!"clang"}
166; CHECK: !2 = !{!3}
167; CHECK: !3 = distinct !{!3, !4, !"test_loop_rotate_XX: pA:pre.rot"}
168; CHECK: !4 = distinct !{!4, !"test_loop_rotate_XX"}
169; CHECK: !5 = !{!6}
170; CHECK: !6 = distinct !{!6, !4, !"test_loop_rotate_XX: pA"}
171; CHECK: !7 = !{!8}
172; CHECK: !8 = distinct !{!8, !4, !"test_loop_rotate_XX: pA:h.rot"}
173; CHECK: !9 = !{!10}
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"}
181