addrec-gep.ll 2.9 KB

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