addrec-gep-address-space.ll 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ; RUN: opt < %s -loop-reduce -S | FileCheck %s
  2. ; CHECK: bb1:
  3. ; CHECK: load double, double addrspace(1)* [[IV:%[^,]+]]
  4. ; CHECK: store double {{.*}}, double addrspace(1)* [[IV]]
  5. ; CHECK-NOT: cast
  6. ; Make sure the GEP has the right index type
  7. ; CHECK: getelementptr double, double addrspace(1)* [[IV]], i16 1
  8. ; CHECK: br {{.*}} label %bb1
  9. ; Make sure the GEP has the right index type
  10. ; CHECK: getelementptr double, double addrspace(1)* {{.*}}, i16
  11. ; This test tests several things. The load and store should use the
  12. ; same address instead of having it computed twice, and SCEVExpander should
  13. ; be able to reconstruct the full getelementptr, despite it having a few
  14. ; obstacles set in its way.
  15. ; We only check that the inner loop (bb1-bb2) is "reduced" because LSR
  16. ; currently only operates on inner loops.
  17. target datalayout = "e-p:64:64:64-p1:16:16:16-n16:32:64"
  18. define void @foo(i64 %n, i64 %m, i64 %o, i64 %q, double addrspace(1)* nocapture %p) nounwind {
  19. entry:
  20. %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1]
  21. br i1 %tmp, label %bb.nph3, label %return
  22. bb.nph: ; preds = %bb2.preheader
  23. %tmp1 = mul i64 %tmp16, %i.02 ; <i64> [#uses=1]
  24. %tmp2 = mul i64 %tmp19, %i.02 ; <i64> [#uses=1]
  25. br label %bb1
  26. bb1: ; preds = %bb2, %bb.nph
  27. %j.01 = phi i64 [ %tmp9, %bb2 ], [ 0, %bb.nph ] ; <i64> [#uses=3]
  28. %tmp3 = add i64 %j.01, %tmp1 ; <i64> [#uses=1]
  29. %tmp4 = add i64 %j.01, %tmp2 ; <i64> [#uses=1]
  30. %z0 = add i64 %tmp3, 5203
  31. %tmp5 = getelementptr double, double addrspace(1)* %p, i64 %z0 ; <double addrspace(1)*> [#uses=1]
  32. %tmp6 = load double, double addrspace(1)* %tmp5, align 8 ; <double> [#uses=1]
  33. %tmp7 = fdiv double %tmp6, 2.100000e+00 ; <double> [#uses=1]
  34. %z1 = add i64 %tmp4, 5203
  35. %tmp8 = getelementptr double, double addrspace(1)* %p, i64 %z1 ; <double addrspace(1)*> [#uses=1]
  36. store double %tmp7, double addrspace(1)* %tmp8, align 8
  37. %tmp9 = add i64 %j.01, 1 ; <i64> [#uses=2]
  38. br label %bb2
  39. bb2: ; preds = %bb1
  40. %tmp10 = icmp slt i64 %tmp9, %m ; <i1> [#uses=1]
  41. br i1 %tmp10, label %bb1, label %bb2.bb3_crit_edge
  42. bb2.bb3_crit_edge: ; preds = %bb2
  43. br label %bb3
  44. bb3: ; preds = %bb2.preheader, %bb2.bb3_crit_edge
  45. %tmp11 = add i64 %i.02, 1 ; <i64> [#uses=2]
  46. br label %bb4
  47. bb4: ; preds = %bb3
  48. %tmp12 = icmp slt i64 %tmp11, %n ; <i1> [#uses=1]
  49. br i1 %tmp12, label %bb2.preheader, label %bb4.return_crit_edge
  50. bb4.return_crit_edge: ; preds = %bb4
  51. br label %bb4.return_crit_edge.split
  52. bb4.return_crit_edge.split: ; preds = %bb.nph3, %bb4.return_crit_edge
  53. br label %return
  54. bb.nph3: ; preds = %entry
  55. %tmp13 = icmp sgt i64 %m, 0 ; <i1> [#uses=1]
  56. %tmp14 = mul i64 %n, 37 ; <i64> [#uses=1]
  57. %tmp15 = mul i64 %tmp14, %o ; <i64> [#uses=1]
  58. %tmp16 = mul i64 %tmp15, %q ; <i64> [#uses=1]
  59. %tmp17 = mul i64 %n, 37 ; <i64> [#uses=1]
  60. %tmp18 = mul i64 %tmp17, %o ; <i64> [#uses=1]
  61. %tmp19 = mul i64 %tmp18, %q ; <i64> [#uses=1]
  62. br i1 %tmp13, label %bb.nph3.split, label %bb4.return_crit_edge.split
  63. bb.nph3.split: ; preds = %bb.nph3
  64. br label %bb2.preheader
  65. bb2.preheader: ; preds = %bb.nph3.split, %bb4
  66. %i.02 = phi i64 [ %tmp11, %bb4 ], [ 0, %bb.nph3.split ] ; <i64> [#uses=3]
  67. br i1 true, label %bb.nph, label %bb3
  68. return: ; preds = %bb4.return_crit_edge.split, %entry
  69. ret void
  70. }