simple-ldstr.ll 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. 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-S128"
  2. ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s
  3. ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-aligned-only -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-AO
  4. ; Simple 3-pair chain with loads and stores
  5. define void @test1(double* %a, double* %b, double* %c) nounwind uwtable readonly {
  6. entry:
  7. %i0 = load double, double* %a, align 8
  8. %i1 = load double, double* %b, align 8
  9. %mul = fmul double %i0, %i1
  10. %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
  11. %i3 = load double, double* %arrayidx3, align 8
  12. %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
  13. %i4 = load double, double* %arrayidx4, align 8
  14. %mul5 = fmul double %i3, %i4
  15. store double %mul, double* %c, align 8
  16. %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
  17. store double %mul5, double* %arrayidx5, align 8
  18. ret void
  19. ; CHECK-LABEL: @test1(
  20. ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
  21. ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
  22. ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8
  23. ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8
  24. ; CHECK: %mul = fmul <2 x double> %i0, %i1
  25. ; CHECK: %0 = bitcast double* %c to <2 x double>*
  26. ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8
  27. ; CHECK: ret void
  28. ; CHECK-AO-LABEL: @test1(
  29. ; CHECK-AO-NOT: <2 x double>
  30. }
  31. ; Simple chain with extending loads and stores
  32. define void @test2(float* %a, float* %b, double* %c) nounwind uwtable readonly {
  33. entry:
  34. %i0f = load float, float* %a, align 4
  35. %i0 = fpext float %i0f to double
  36. %i1f = load float, float* %b, align 4
  37. %i1 = fpext float %i1f to double
  38. %mul = fmul double %i0, %i1
  39. %arrayidx3 = getelementptr inbounds float, float* %a, i64 1
  40. %i3f = load float, float* %arrayidx3, align 4
  41. %i3 = fpext float %i3f to double
  42. %arrayidx4 = getelementptr inbounds float, float* %b, i64 1
  43. %i4f = load float, float* %arrayidx4, align 4
  44. %i4 = fpext float %i4f to double
  45. %mul5 = fmul double %i3, %i4
  46. store double %mul, double* %c, align 8
  47. %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
  48. store double %mul5, double* %arrayidx5, align 8
  49. ret void
  50. ; CHECK-LABEL: @test2(
  51. ; CHECK: %i0f.v.i0 = bitcast float* %a to <2 x float>*
  52. ; CHECK: %i1f.v.i0 = bitcast float* %b to <2 x float>*
  53. ; CHECK: %i0f = load <2 x float>, <2 x float>* %i0f.v.i0, align 4
  54. ; CHECK: %i0 = fpext <2 x float> %i0f to <2 x double>
  55. ; CHECK: %i1f = load <2 x float>, <2 x float>* %i1f.v.i0, align 4
  56. ; CHECK: %i1 = fpext <2 x float> %i1f to <2 x double>
  57. ; CHECK: %mul = fmul <2 x double> %i0, %i1
  58. ; CHECK: %0 = bitcast double* %c to <2 x double>*
  59. ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8
  60. ; CHECK: ret void
  61. ; CHECK-AO-LABEL: @test2(
  62. ; CHECK-AO-NOT: <2 x double>
  63. }
  64. ; Simple chain with loads and truncating stores
  65. define void @test3(double* %a, double* %b, float* %c) nounwind uwtable readonly {
  66. entry:
  67. %i0 = load double, double* %a, align 8
  68. %i1 = load double, double* %b, align 8
  69. %mul = fmul double %i0, %i1
  70. %mulf = fptrunc double %mul to float
  71. %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
  72. %i3 = load double, double* %arrayidx3, align 8
  73. %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
  74. %i4 = load double, double* %arrayidx4, align 8
  75. %mul5 = fmul double %i3, %i4
  76. %mul5f = fptrunc double %mul5 to float
  77. store float %mulf, float* %c, align 8
  78. %arrayidx5 = getelementptr inbounds float, float* %c, i64 1
  79. store float %mul5f, float* %arrayidx5, align 4
  80. ret void
  81. ; CHECK-LABEL: @test3(
  82. ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
  83. ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
  84. ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8
  85. ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8
  86. ; CHECK: %mul = fmul <2 x double> %i0, %i1
  87. ; CHECK: %mulf = fptrunc <2 x double> %mul to <2 x float>
  88. ; CHECK: %0 = bitcast float* %c to <2 x float>*
  89. ; CHECK: store <2 x float> %mulf, <2 x float>* %0, align 8
  90. ; CHECK: ret void
  91. ; CHECK-AO-LABEL: @test3(
  92. ; CHECK-AO: %i0 = load double, double* %a, align 8
  93. ; CHECK-AO: %i1 = load double, double* %b, align 8
  94. ; CHECK-AO: %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
  95. ; CHECK-AO: %i3 = load double, double* %arrayidx3, align 8
  96. ; CHECK-AO: %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
  97. ; CHECK-AO: %i4 = load double, double* %arrayidx4, align 8
  98. ; CHECK-AO: %mul.v.i1.1 = insertelement <2 x double> undef, double %i1, i32 0
  99. ; CHECK-AO: %mul.v.i1.2 = insertelement <2 x double> %mul.v.i1.1, double %i4, i32 1
  100. ; CHECK-AO: %mul.v.i0.1 = insertelement <2 x double> undef, double %i0, i32 0
  101. ; CHECK-AO: %mul.v.i0.2 = insertelement <2 x double> %mul.v.i0.1, double %i3, i32 1
  102. ; CHECK-AO: %mul = fmul <2 x double> %mul.v.i0.2, %mul.v.i1.2
  103. ; CHECK-AO: %mulf = fptrunc <2 x double> %mul to <2 x float>
  104. ; CHECK-AO: %0 = bitcast float* %c to <2 x float>*
  105. ; CHECK-AO: store <2 x float> %mulf, <2 x float>* %0, align 8
  106. ; CHECK-AO: ret void
  107. }
  108. ; Simple 3-pair chain with loads and stores (unreachable)
  109. define void @test4(i1 %bool, double* %a, double* %b, double* %c) nounwind uwtable readonly {
  110. entry:
  111. br i1 %bool, label %if.then1, label %if.end
  112. if.then1:
  113. unreachable
  114. br label %if.then
  115. if.then:
  116. %i0 = load double, double* %a, align 8
  117. %i1 = load double, double* %b, align 8
  118. %mul = fmul double %i0, %i1
  119. %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
  120. %i3 = load double, double* %arrayidx3, align 8
  121. %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
  122. %i4 = load double, double* %arrayidx4, align 8
  123. %mul5 = fmul double %i3, %i4
  124. store double %mul, double* %c, align 8
  125. %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
  126. store double %mul5, double* %arrayidx5, align 8
  127. br label %if.end
  128. if.end:
  129. ret void
  130. ; CHECK-LABEL: @test4(
  131. ; CHECK-NOT: <2 x double>
  132. ; CHECK-AO-LABEL: @test4(
  133. ; CHECK-AO-NOT: <2 x double>
  134. }
  135. ; Simple 3-pair chain with loads and stores
  136. define void @test5(double* %a, double* %b, double* %c) nounwind uwtable readonly {
  137. entry:
  138. %i0 = load double, double* %a, align 8
  139. %i1 = load double, double* %b, align 8
  140. %mul = fmul double %i0, %i1
  141. %arrayidx3 = getelementptr inbounds double, double* %a, i64 1
  142. %i3 = load double, double* %arrayidx3, align 8
  143. %arrayidx4 = getelementptr inbounds double, double* %b, i64 1
  144. %i4 = load double, double* %arrayidx4, align 8
  145. %mul5 = fmul double %i3, %i4
  146. %arrayidx5 = getelementptr inbounds double, double* %c, i64 1
  147. store double %mul5, double* %arrayidx5, align 8
  148. store double %mul, double* %c, align 4
  149. ret void
  150. ; CHECK-LABEL: @test5(
  151. ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
  152. ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
  153. ; CHECK: %i0 = load <2 x double>, <2 x double>* %i0.v.i0, align 8
  154. ; CHECK: %i1 = load <2 x double>, <2 x double>* %i1.v.i0, align 8
  155. ; CHECK: %mul = fmul <2 x double> %i0, %i1
  156. ; CHECK: %0 = bitcast double* %c to <2 x double>*
  157. ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 4
  158. ; CHECK: ret void
  159. ; CHECK-AO-LABEL: @test5(
  160. ; CHECK-AO-NOT: <2 x double>
  161. }