dynamic-indices.ll 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s
  2. ; PR9971
  3. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
  4. %struct.X = type { i32, float }
  5. %union.vector_t = type { [2 x i64] }
  6. ; Don't delete the load after the loop, because it loads values stored
  7. ; inside the loop.
  8. ; CHECK: define void @vrlh(
  9. ; CHECK: for.end:
  10. ; CHECK: %arrayidx31 = getelementptr inbounds %union.vector_t, %union.vector_t* %t, i64 0, i32 0, i64 1
  11. ; CHECK: %tmp32 = load i64, i64* %arrayidx31, align 8, !tbaa [[TAG:!.*]]
  12. define void @vrlh(%union.vector_t* %va, %union.vector_t* %vb, %union.vector_t* %vd) nounwind {
  13. entry:
  14. %t = alloca %union.vector_t, align 8
  15. br label %for.body
  16. for.body: ; preds = %entry, %for.body
  17. %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  18. %sub = sub nsw i32 7, %i.01
  19. %idxprom = sext i32 %sub to i64
  20. %half = bitcast %union.vector_t* %vb to [8 x i16]*
  21. %arrayidx = getelementptr inbounds [8 x i16], [8 x i16]* %half, i64 0, i64 %idxprom
  22. %tmp4 = load i16, i16* %arrayidx, align 2, !tbaa !0
  23. %conv = zext i16 %tmp4 to i32
  24. %and = and i32 %conv, 15
  25. %sub6 = sub nsw i32 7, %i.01
  26. %idxprom7 = sext i32 %sub6 to i64
  27. %half9 = bitcast %union.vector_t* %va to [8 x i16]*
  28. %arrayidx10 = getelementptr inbounds [8 x i16], [8 x i16]* %half9, i64 0, i64 %idxprom7
  29. %tmp11 = load i16, i16* %arrayidx10, align 2, !tbaa !0
  30. %conv12 = zext i16 %tmp11 to i32
  31. %shl = shl i32 %conv12, %and
  32. %sub15 = sub nsw i32 7, %i.01
  33. %idxprom16 = sext i32 %sub15 to i64
  34. %half18 = bitcast %union.vector_t* %va to [8 x i16]*
  35. %arrayidx19 = getelementptr inbounds [8 x i16], [8 x i16]* %half18, i64 0, i64 %idxprom16
  36. %tmp20 = load i16, i16* %arrayidx19, align 2, !tbaa !0
  37. %conv21 = zext i16 %tmp20 to i32
  38. %sub23 = sub nsw i32 16, %and
  39. %shr = lshr i32 %conv21, %sub23
  40. %or = or i32 %shl, %shr
  41. %conv24 = trunc i32 %or to i16
  42. %sub26 = sub nsw i32 7, %i.01
  43. %idxprom27 = sext i32 %sub26 to i64
  44. %half28 = bitcast %union.vector_t* %t to [8 x i16]*
  45. %arrayidx29 = getelementptr inbounds [8 x i16], [8 x i16]* %half28, i64 0, i64 %idxprom27
  46. store i16 %conv24, i16* %arrayidx29, align 2, !tbaa !0
  47. %inc = add nsw i32 %i.01, 1
  48. %cmp = icmp slt i32 %inc, 8
  49. br i1 %cmp, label %for.body, label %for.end
  50. for.end: ; preds = %for.body
  51. %arrayidx31 = getelementptr inbounds %union.vector_t, %union.vector_t* %t, i64 0, i32 0, i64 1
  52. %tmp32 = load i64, i64* %arrayidx31, align 8, !tbaa !3
  53. %arrayidx35 = getelementptr inbounds %union.vector_t, %union.vector_t* %vd, i64 0, i32 0, i64 1
  54. store i64 %tmp32, i64* %arrayidx35, align 8, !tbaa !3
  55. %arrayidx37 = getelementptr inbounds %union.vector_t, %union.vector_t* %t, i64 0, i32 0, i64 0
  56. %tmp38 = load i64, i64* %arrayidx37, align 8, !tbaa !3
  57. %arrayidx41 = getelementptr inbounds %union.vector_t, %union.vector_t* %vd, i64 0, i32 0, i64 0
  58. store i64 %tmp38, i64* %arrayidx41, align 8, !tbaa !3
  59. ret void
  60. }
  61. ; Do delete the load after the loop.
  62. ; CHECK: define i32 @test0(
  63. ; CHECK: ret i32 0
  64. define i32 @test0(%struct.X* %a) nounwind {
  65. entry:
  66. %i = getelementptr inbounds %struct.X, %struct.X* %a, i64 0, i32 0
  67. store i32 0, i32* %i, align 4, !tbaa !4
  68. br label %for.body
  69. for.body: ; preds = %entry, %for.body
  70. %i2.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
  71. %f = getelementptr inbounds %struct.X, %struct.X* %a, i64 %i2.01, i32 1
  72. %tmp6 = load float, float* %f, align 4, !tbaa !5
  73. %mul = fmul float %tmp6, 0x40019999A0000000
  74. store float %mul, float* %f, align 4, !tbaa !5
  75. %inc = add nsw i64 %i2.01, 1
  76. %cmp = icmp slt i64 %inc, 10000
  77. br i1 %cmp, label %for.body, label %for.end
  78. for.end: ; preds = %for.body
  79. %i9 = getelementptr inbounds %struct.X, %struct.X* %a, i64 0, i32 0
  80. %tmp10 = load i32, i32* %i9, align 4, !tbaa !4
  81. ret i32 %tmp10
  82. }
  83. ; Do delete the load after the loop.
  84. ; CHECK: define float @test1(
  85. ; CHECK: ret float 0x3FD3333340000000
  86. define float @test1(%struct.X* %a) nounwind {
  87. entry:
  88. %f = getelementptr inbounds %struct.X, %struct.X* %a, i64 0, i32 1
  89. store float 0x3FD3333340000000, float* %f, align 4, !tbaa !5
  90. br label %for.body
  91. for.body: ; preds = %entry, %for.body
  92. %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
  93. %i5 = getelementptr inbounds %struct.X, %struct.X* %a, i64 %i.01, i32 0
  94. %tmp6 = load i32, i32* %i5, align 4, !tbaa !4
  95. %mul = mul nsw i32 %tmp6, 3
  96. store i32 %mul, i32* %i5, align 4, !tbaa !4
  97. %inc = add nsw i64 %i.01, 1
  98. %cmp = icmp slt i64 %inc, 10000
  99. br i1 %cmp, label %for.body, label %for.end
  100. for.end: ; preds = %for.body
  101. %f9 = getelementptr inbounds %struct.X, %struct.X* %a, i64 0, i32 1
  102. %tmp10 = load float, float* %f9, align 4, !tbaa !5
  103. ret float %tmp10
  104. }
  105. ; CHECK: [[TAG]] = !{[[TYPE_LL:!.*]], [[TYPE_LL]], i64 0}
  106. ; CHECK: [[TYPE_LL]] = !{!"long long", {{!.*}}}
  107. !0 = !{!6, !6, i64 0}
  108. !1 = !{!"omnipotent char", !2}
  109. !2 = !{!"Simple C/C++ TBAA", null}
  110. !3 = !{!7, !7, i64 0}
  111. !4 = !{!8, !8, i64 0}
  112. !5 = !{!9, !9, i64 0}
  113. !6 = !{!"short", !1}
  114. !7 = !{!"long long", !1}
  115. !8 = !{!"int", !1}
  116. !9 = !{!"float", !1}