1 ; RUN: opt < %s -tbaa -basicaa -loop-vectorize -force-vector-unroll=1 -force-vector-width=4 -dce -instcombine -simplifycfg -S | FileCheck %s
2 ; RUN: opt < %s -basicaa -loop-vectorize -force-vector-unroll=1 -force-vector-width=4 -dce -instcombine -simplifycfg -S | FileCheck %s --check-prefix=CHECK-NOTBAA
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; Function Attrs: nounwind uwtable
7 define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) #0 {
11 for.body: ; preds = %for.body, %entry
12 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
13 %arrayidx = getelementptr inbounds float* %b, i64 %indvars.iv
14 %0 = load float* %arrayidx, align 4, !tbaa !0
15 %conv = fptosi float %0 to i32
16 %arrayidx2 = getelementptr inbounds i32* %a, i64 %indvars.iv
17 store i32 %conv, i32* %arrayidx2, align 4, !tbaa !4
18 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
19 %exitcond = icmp eq i64 %indvars.iv.next, 1600
20 br i1 %exitcond, label %for.end, label %for.body
22 for.end: ; preds = %for.body
25 ; TBAA partitions the accesses in this loop, so it can be vectorized without
30 ; CHECK-NEXT: br label %vector.body
33 ; CHECK: load <4 x float>* %{{.*}}, align 4, !tbaa
34 ; CHECK: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
38 ; CHECK-NOTBAA-LABEL: @test1
39 ; CHECK-NOTBAA: icmp uge i32*
41 ; CHECK-NOTBAA: load <4 x float>* %{{.*}}, align 4, !tbaa
42 ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
44 ; CHECK-NOTBAA: ret i32 0
47 ; Function Attrs: nounwind uwtable
48 define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) #0 {
52 for.body: ; preds = %for.body, %entry
53 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
54 %arrayidx = getelementptr inbounds float* %b, i64 %indvars.iv
55 %0 = load float* %arrayidx, align 4, !tbaa !0
56 %arrayidx2 = getelementptr inbounds i32* %a, i64 %indvars.iv
57 %1 = load i32* %arrayidx2, align 4, !tbaa !4
58 %conv = sitofp i32 %1 to float
59 %mul = fmul float %0, %conv
60 %arrayidx4 = getelementptr inbounds float* %c, i64 %indvars.iv
61 store float %mul, float* %arrayidx4, align 4, !tbaa !0
62 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
63 %exitcond = icmp eq i64 %indvars.iv.next, 1600
64 br i1 %exitcond, label %for.end, label %for.body
66 for.end: ; preds = %for.body
69 ; This test is like the first, except here there is still one runtime check
70 ; required. Without TBAA, however, two checks are required.
73 ; CHECK: icmp uge float*
74 ; CHECK: icmp uge float*
75 ; CHECK-NOT: icmp uge i32*
77 ; CHECK: load <4 x float>* %{{.*}}, align 4, !tbaa
78 ; CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
82 ; CHECK-NOTBAA-LABEL: @test2
83 ; CHECK-NOTBAA: icmp uge float*
84 ; CHECK-NOTBAA: icmp uge float*
85 ; CHECK-NOTBAA-DAG: icmp uge float*
86 ; CHECK-NOTBAA-DAG: icmp uge i32*
88 ; CHECK-NOTBAA: load <4 x float>* %{{.*}}, align 4, !tbaa
89 ; CHECK-NOTBAA: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
91 ; CHECK-NOTBAA: ret i32 0
94 attributes #0 = { nounwind uwtable }
96 !0 = metadata !{metadata !1, metadata !1, i64 0}
97 !1 = metadata !{metadata !"float", metadata !2, i64 0}
98 !2 = metadata !{metadata !"omnipotent char", metadata !3, i64 0}
99 !3 = metadata !{metadata !"Simple C/C++ TBAA"}
100 !4 = metadata !{metadata !5, metadata !5, i64 0}
101 !5 = metadata !{metadata !"int", metadata !2, i64 0}