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
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 ; TBAA partitions the accesses in this loop, so it can be vectorized without
7 define i32 @test1(ptr nocapture %a, ptr nocapture readonly %b) {
10 ; CHECK-NEXT: br label %vector.body
13 ; CHECK: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
14 ; CHECK: store <4 x i32> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
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
24 ; CHECK-NOTBAA: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
25 ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
27 ; CHECK-NOTBAA: ret i32 0
32 for.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
43 for.end: ; preds = %for.body
47 ; This test is like the first, except here there is still one runtime check
48 ; required. Without TBAA, however, two checks are required.
49 define i32 @test2(ptr nocapture readonly %a, ptr nocapture readonly %b, ptr nocapture %c) {
54 ; CHECK: br i1 {{.+}}, label %for.body, label %vector.body
56 ; CHECK: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
57 ; CHECK: store <4 x float> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
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
68 ; CHECK-NOTBAA: load <4 x float>, ptr %{{.*}}, align 4, !tbaa
69 ; CHECK-NOTBAA: store <4 x float> %{{.*}}, ptr %{{.*}}, align 4, !tbaa
71 ; CHECK-NOTBAA: ret i32 0
76 for.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
90 for.end: ; preds = %for.body
95 !1 = !{!"float", !2, i64 0}
96 !2 = !{!"omnipotent char", !3, i64 0}
97 !3 = !{!"Simple C/C++ TBAA"}
99 !5 = !{!"int", !2, i64 0}