2
0

tbaa-nodep.ll 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. ; Function Attrs: nounwind uwtable
  6. define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) #0 {
  7. entry:
  8. br label %for.body
  9. for.body: ; preds = %for.body, %entry
  10. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  11. %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
  12. %0 = load float, float* %arrayidx, align 4, !tbaa !0
  13. %conv = fptosi float %0 to i32
  14. %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
  15. store i32 %conv, i32* %arrayidx2, align 4, !tbaa !4
  16. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  17. %exitcond = icmp eq i64 %indvars.iv.next, 1600
  18. br i1 %exitcond, label %for.end, label %for.body
  19. for.end: ; preds = %for.body
  20. ret i32 0
  21. ; TBAA partitions the accesses in this loop, so it can be vectorized without
  22. ; runtime checks.
  23. ; CHECK-LABEL: @test1
  24. ; CHECK: entry:
  25. ; CHECK-NEXT: br label %vector.body
  26. ; CHECK: vector.body:
  27. ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
  28. ; CHECK: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
  29. ; CHECK: ret i32 0
  30. ; CHECK-NOTBAA-LABEL: @test1
  31. ; CHECK-NOTBAA: icmp uge i32*
  32. ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
  33. ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
  34. ; CHECK-NOTBAA: ret i32 0
  35. }
  36. ; Function Attrs: nounwind uwtable
  37. define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) #0 {
  38. entry:
  39. br label %for.body
  40. for.body: ; preds = %for.body, %entry
  41. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  42. %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
  43. %0 = load float, float* %arrayidx, align 4, !tbaa !0
  44. %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
  45. %1 = load i32, i32* %arrayidx2, align 4, !tbaa !4
  46. %conv = sitofp i32 %1 to float
  47. %mul = fmul float %0, %conv
  48. %arrayidx4 = getelementptr inbounds float, float* %c, i64 %indvars.iv
  49. store float %mul, float* %arrayidx4, align 4, !tbaa !0
  50. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  51. %exitcond = icmp eq i64 %indvars.iv.next, 1600
  52. br i1 %exitcond, label %for.end, label %for.body
  53. for.end: ; preds = %for.body
  54. ret i32 0
  55. ; This test is like the first, except here there is still one runtime check
  56. ; required. Without TBAA, however, two checks are required.
  57. ; CHECK-LABEL: @test2
  58. ; CHECK: icmp uge float*
  59. ; CHECK: icmp uge float*
  60. ; CHECK-NOT: icmp uge i32*
  61. ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
  62. ; CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
  63. ; CHECK: ret i32 0
  64. ; CHECK-NOTBAA-LABEL: @test2
  65. ; CHECK-NOTBAA: icmp uge float*
  66. ; CHECK-NOTBAA: icmp uge float*
  67. ; CHECK-NOTBAA-DAG: icmp uge float*
  68. ; CHECK-NOTBAA-DAG: icmp uge i32*
  69. ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
  70. ; CHECK-NOTBAA: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
  71. ; CHECK-NOTBAA: ret i32 0
  72. }
  73. attributes #0 = { nounwind uwtable }
  74. !0 = !{!1, !1, i64 0}
  75. !1 = !{!"float", !2, i64 0}
  76. !2 = !{!"omnipotent char", !3, i64 0}
  77. !3 = !{!"Simple C/C++ TBAA"}
  78. !4 = !{!5, !5, i64 0}
  79. !5 = !{!"int", !2, i64 0}