1 ; RUN: opt < %s -tbaa -basicaa -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -simplifycfg -S | FileCheck %s 2 ; RUN: opt < %s -basicaa -loop-vectorize -force-vector-interleave=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" 5 6 ; Function Attrs: nounwind uwtable 7 define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) #0 { 8 entry: 9 br label %for.body 10 11 for.body: ; preds = %for.body, %entry 12 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 13 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv 14 %0 = load float, float* %arrayidx, align 4, !tbaa !0 15 %conv = fptosi float %0 to i32 16 %arrayidx2 = getelementptr inbounds i32, 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 21 22 for.end: ; preds = %for.body 23 ret i32 0 24 25 ; TBAA partitions the accesses in this loop, so it can be vectorized without 26 ; runtime checks. 27 28 ; CHECK-LABEL: @test1 29 ; CHECK: entry: 30 ; CHECK-NEXT: br label %vector.body 31 ; CHECK: vector.body: 32 33 ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa 34 ; CHECK: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa 35 36 ; CHECK: ret i32 0 37 38 ; CHECK-NOTBAA-LABEL: @test1 39 ; CHECK-NOTBAA: icmp uge i32* 40 41 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa 42 ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa 43 44 ; CHECK-NOTBAA: ret i32 0 45 } 46 47 ; Function Attrs: nounwind uwtable 48 define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) #0 { 49 entry: 50 br label %for.body 51 52 for.body: ; preds = %for.body, %entry 53 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 54 %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv 55 %0 = load float, float* %arrayidx, align 4, !tbaa !0 56 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv 57 %1 = load i32, i32* %arrayidx2, align 4, !tbaa !4 58 %conv = sitofp i32 %1 to float 59 %mul = fmul float %0, %conv 60 %arrayidx4 = getelementptr inbounds float, 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 65 66 for.end: ; preds = %for.body 67 ret i32 0 68 69 ; This test is like the first, except here there is still one runtime check 70 ; required. Without TBAA, however, two checks are required. 71 72 ; CHECK-LABEL: @test2 73 ; CHECK: icmp uge float* 74 ; CHECK: icmp uge float* 75 ; CHECK-NOT: icmp uge i32* 76 77 ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa 78 ; CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa 79 80 ; CHECK: ret i32 0 81 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* 87 88 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa 89 ; CHECK-NOTBAA: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa 90 91 ; CHECK-NOTBAA: ret i32 0 92 } 93 94 attributes #0 = { nounwind uwtable } 95 96 !0 = !{!1, !1, i64 0} 97 !1 = !{!"float", !2, i64 0} 98 !2 = !{!"omnipotent char", !3, i64 0} 99 !3 = !{!"Simple C/C++ TBAA"} 100 !4 = !{!5, !5, i64 0} 101 !5 = !{!"int", !2, i64 0} 102 103