xref: /llvm-project/llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll (revision 7d7577256b76e4293f455b8093504d5f7044ab4b)
1; RUN: opt < %s  -aa-pipeline=tbaa,basic-aa -passes=loop-vectorize,dce,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=4 -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
2; RUN: opt < %s  -aa-pipeline=basic-aa -passes=loop-vectorize,dce,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=4 -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s --check-prefix=CHECK-NOTBAA
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4
5; TBAA partitions the accesses in this loop, so it can be vectorized without
6; runtime checks.
7define i32 @test1(ptr nocapture %a, ptr nocapture readonly %b) {
8; CHECK-LABEL: @test1
9; CHECK: entry:
10; CHECK-NEXT: br label %vector.body
11; CHECK: vector.body:
12
13; CHECK: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
14; CHECK: store <4 x i32> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
15
16; CHECK: ret i32 0
17
18; CHECK-NOTBAA-LABEL: @test1
19; CHECK-NOTBAA: entry:
20; CHECK-NOTBAA: icmp ult i64
21; CHECK-NOTBAA-NOT: icmp
22; CHECK-NOTBAA: br i1 {{.+}}, label %for.body, label %vector.body
23
24; CHECK-NOTBAA: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
25; CHECK-NOTBAA: store <4 x i32> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
26
27; CHECK-NOTBAA: ret i32 0
28
29entry:
30  br label %for.body
31
32for.body:                                         ; preds = %for.body, %entry
33  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
34  %arrayidx = getelementptr inbounds float, ptr %b, i64 %indvars.iv
35  %0 = load float, ptr %arrayidx, align 4, !tbaa !0
36  %conv = fptosi float %0 to i32
37  %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
38  store i32 %conv, ptr %arrayidx2, align 4, !tbaa !4
39  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
40  %exitcond = icmp eq i64 %indvars.iv.next, 1600
41  br i1 %exitcond, label %for.end, label %for.body
42
43for.end:                                          ; preds = %for.body
44  ret i32 0
45}
46
47; This test is like the first, except here there is still one runtime check
48; required. Without TBAA, however, two checks are required.
49define i32 @test2(ptr nocapture readonly %a, ptr nocapture readonly %b, ptr nocapture %c) {
50; CHECK-LABEL: @test2
51; CHECK: entry:
52; CHECK: icmp ult i64
53; CHECK-NOT: icmp
54; CHECK: br i1 {{.+}}, label %for.body, label %vector.body
55
56; CHECK: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
57; CHECK: store <4 x float> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
58
59; CHECK: ret i32 0
60
61; CHECK-NOTBAA-LABEL: @test2
62; CHECK-NOTBAA: entry:
63; CHECK-NOTBAA: icmp ult i64
64; CHECK-NOTBAA: icmp ult i64
65; CHECK-NOTBAA-NOT: icmp
66; CHECK-NOTBAA: br i1 {{.+}}, label %for.body, label %vector.body
67
68; CHECK-NOTBAA: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
69; CHECK-NOTBAA: store <4 x float> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
70
71; CHECK-NOTBAA: ret i32 0
72
73entry:
74  br label %for.body
75
76for.body:                                         ; preds = %for.body, %entry
77  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
78  %arrayidx = getelementptr inbounds float, ptr %b, i64 %indvars.iv
79  %0 = load float, ptr %arrayidx, align 4, !tbaa !0
80  %arrayidx2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
81  %1 = load i32, ptr %arrayidx2, align 4, !tbaa !4
82  %conv = sitofp i32 %1 to float
83  %mul = fmul float %0, %conv
84  %arrayidx4 = getelementptr inbounds float, ptr %c, i64 %indvars.iv
85  store float %mul, ptr %arrayidx4, align 4, !tbaa !0
86  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
87  %exitcond = icmp eq i64 %indvars.iv.next, 1600
88  br i1 %exitcond, label %for.end, label %for.body
89
90for.end:                                          ; preds = %for.body
91  ret i32 0
92}
93
94!0 = !{!1, !1, i64 0}
95!1 = !{!"float", !2, i64 0}
96!2 = !{!"omnipotent char", !3, i64 0}
97!3 = !{!"Simple C/C++ TBAA"}
98!4 = !{!5, !5, i64 0}
99!5 = !{!"int", !2, i64 0}
100