1 ; RUN: opt < %s -tbaa -basic-aa -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
2 ; RUN: opt < %s -basic-aa -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -simplifycfg -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 ; Function Attrs: nounwind uwtable
6 define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) #0 {
10 for.body: ; preds = %for.body, %entry
11 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
12 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
13 %0 = load float, float* %arrayidx, align 4, !tbaa !0
14 %conv = fptosi float %0 to i32
15 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
16 store i32 %conv, i32* %arrayidx2, align 4, !tbaa !4
17 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
18 %exitcond = icmp eq i64 %indvars.iv.next, 1600
19 br i1 %exitcond, label %for.end, label %for.body
21 for.end: ; preds = %for.body
24 ; TBAA partitions the accesses in this loop, so it can be vectorized without
29 ; CHECK-NEXT: br label %vector.body
32 ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
33 ; CHECK: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
37 ; CHECK-NOTBAA-LABEL: @test1
38 ; CHECK-NOTBAA: icmp ugt i32*
40 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
41 ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
43 ; CHECK-NOTBAA: ret i32 0
46 ; Function Attrs: nounwind uwtable
47 define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) #0 {
51 for.body: ; preds = %for.body, %entry
52 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
53 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
54 %0 = load float, float* %arrayidx, align 4, !tbaa !0
55 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
56 %1 = load i32, i32* %arrayidx2, align 4, !tbaa !4
57 %conv = sitofp i32 %1 to float
58 %mul = fmul float %0, %conv
59 %arrayidx4 = getelementptr inbounds float, float* %c, i64 %indvars.iv
60 store float %mul, float* %arrayidx4, align 4, !tbaa !0
61 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
62 %exitcond = icmp eq i64 %indvars.iv.next, 1600
63 br i1 %exitcond, label %for.end, label %for.body
65 for.end: ; preds = %for.body
68 ; This test is like the first, except here there is still one runtime check
69 ; required. Without TBAA, however, two checks are required.
72 ; CHECK: icmp ugt float*
73 ; CHECK: icmp ugt float*
74 ; CHECK-NOT: icmp uge i32*
76 ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
77 ; CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
81 ; CHECK-NOTBAA-LABEL: @test2
82 ; CHECK-NOTBAA: icmp ugt float*
83 ; CHECK-NOTBAA: icmp ugt float*
84 ; CHECK-NOTBAA-DAG: icmp ugt float*
85 ; CHECK-NOTBAA-DAG: icmp ugt i32*
87 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
88 ; CHECK-NOTBAA: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
90 ; CHECK-NOTBAA: ret i32 0
93 attributes #0 = { nounwind uwtable }
96 !1 = !{!"float", !2, i64 0}
97 !2 = !{!"omnipotent char", !3, i64 0}
98 !3 = !{!"Simple C/C++ TBAA"}
100 !5 = !{!"int", !2, i64 0}