2012-03-15-nopreheader.ll 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. ; RUN: opt -loop-reduce -S < %s | FileCheck %s
  2. ;
  3. ; <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce
  4. 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"
  5. target triple = "x86_64-apple-darwin10.0.0"
  6. ; IVUsers should not consider tmp128 a valid user because it is not in a
  7. ; simplified loop nest.
  8. ; CHECK-LABEL: @nopreheader(
  9. ; CHECK: for.cond:
  10. ; CHECK: %tmp128 = add i64 %0, %indvar65
  11. define void @nopreheader(i8* %cmd) nounwind ssp {
  12. entry:
  13. indirectbr i8* undef, [label %while.cond]
  14. while.cond: ; preds = %while.body, %entry
  15. %0 = phi i64 [ %indvar.next48, %while.body ], [ 0, %entry ]
  16. indirectbr i8* undef, [label %while.end, label %while.body]
  17. while.body: ; preds = %lor.rhs, %lor.lhs.false17, %lor.lhs.false11, %lor.lhs.false, %land.rhs
  18. %indvar.next48 = add i64 %0, 1
  19. indirectbr i8* undef, [label %while.cond]
  20. while.end: ; preds = %lor.rhs, %while.cond
  21. indirectbr i8* undef, [label %if.end152]
  22. if.end152: ; preds = %lor.lhs.false144, %if.end110
  23. indirectbr i8* undef, [label %lor.lhs.false184, label %for.cond]
  24. lor.lhs.false184: ; preds = %lor.lhs.false177
  25. indirectbr i8* undef, [label %return, label %for.cond]
  26. for.cond: ; preds = %for.inc, %lor.lhs.false184, %if.end152
  27. %indvar65 = phi i64 [ %indvar.next66, %for.inc ], [ 0, %lor.lhs.false184 ], [ 0, %if.end152 ]
  28. %tmp128 = add i64 %0, %indvar65
  29. %s.4 = getelementptr i8, i8* %cmd, i64 %tmp128
  30. %tmp195 = load i8, i8* %s.4, align 1
  31. indirectbr i8* undef, [label %return, label %land.rhs198]
  32. land.rhs198: ; preds = %for.cond
  33. indirectbr i8* undef, [label %return, label %for.inc]
  34. for.inc: ; preds = %lor.rhs234, %land.lhs.true228, %land.lhs.true216, %land.lhs.true204
  35. %indvar.next66 = add i64 %indvar65, 1
  36. indirectbr i8* undef, [label %for.cond]
  37. return: ; preds = %if.end677, %doshell, %if.then96
  38. ret void
  39. }
  40. ; Another case with a dominating loop that does not contain the IV
  41. ; User. Just make sure it doesn't assert.
  42. define void @nopreheader2() nounwind ssp {
  43. entry:
  44. indirectbr i8* undef, [label %while.cond, label %return]
  45. while.cond: ; preds = %while.cond.backedge, %entry
  46. indirectbr i8* undef, [label %while.cond.backedge, label %lor.rhs]
  47. lor.rhs: ; preds = %while.cond
  48. indirectbr i8* undef, [label %while.cond.backedge, label %while.end]
  49. while.cond.backedge: ; preds = %lor.rhs, %while.cond
  50. indirectbr i8* undef, [label %while.cond]
  51. while.end: ; preds = %lor.rhs
  52. indirectbr i8* undef, [label %if.then18, label %return]
  53. if.then18: ; preds = %while.end
  54. indirectbr i8* undef, [label %if.end35, label %lor.lhs.false]
  55. lor.lhs.false: ; preds = %if.then18
  56. indirectbr i8* undef, [label %if.end35, label %return]
  57. if.end35: ; preds = %lor.lhs.false, %if.then18
  58. indirectbr i8* undef, [label %while.cond36]
  59. while.cond36: ; preds = %while.body49, %if.end35
  60. %0 = phi i64 [ %indvar.next13, %while.body49 ], [ 0, %if.end35 ]
  61. indirectbr i8* undef, [label %while.body49, label %lor.rhs42]
  62. lor.rhs42: ; preds = %while.cond36
  63. indirectbr i8* undef, [label %while.body49, label %while.end52]
  64. while.body49: ; preds = %lor.rhs42, %while.cond36
  65. %indvar.next13 = add i64 %0, 1
  66. indirectbr i8* undef, [label %while.cond36]
  67. while.end52: ; preds = %lor.rhs42
  68. indirectbr i8* undef, [label %land.lhs.true, label %return]
  69. land.lhs.true: ; preds = %while.end52
  70. indirectbr i8* undef, [label %while.cond66.preheader, label %return]
  71. while.cond66.preheader: ; preds = %land.lhs.true
  72. indirectbr i8* undef, [label %while.cond66]
  73. while.cond66: ; preds = %while.body77, %while.cond66.preheader
  74. indirectbr i8* undef, [label %land.rhs, label %while.cond81.preheader]
  75. land.rhs: ; preds = %while.cond66
  76. indirectbr i8* undef, [label %while.body77, label %while.cond81.preheader]
  77. while.cond81.preheader: ; preds = %land.rhs, %while.cond66
  78. %tmp45 = add i64 undef, %0
  79. %tmp46 = add i64 %tmp45, undef
  80. indirectbr i8* undef, [label %while.cond81]
  81. while.body77: ; preds = %land.rhs
  82. indirectbr i8* undef, [label %while.cond66]
  83. while.cond81: ; preds = %while.body94, %while.cond81.preheader
  84. %tmp25 = add i64 %tmp46, undef
  85. indirectbr i8* undef, [label %while.body94, label %lor.rhs87]
  86. lor.rhs87: ; preds = %while.cond81
  87. indirectbr i8* undef, [label %while.body94, label %return]
  88. while.body94: ; preds = %lor.rhs87, %while.cond81
  89. indirectbr i8* undef, [label %while.cond81]
  90. return: ; preds = %if.end216, %land.lhs.true183, %land.lhs.true, %while.end52, %lor.lhs.false, %while.end, %entry
  91. ret void
  92. }
  93. ; Test a phi operand IV User dominated by a no-preheader loop.
  94. define void @nopreheader3() nounwind uwtable ssp align 2 {
  95. entry:
  96. indirectbr i8* blockaddress(@nopreheader3, %if.end10), [label %if.end22, label %if.end10]
  97. if.end10: ; preds = %entry
  98. indirectbr i8* blockaddress(@nopreheader3, %if.end6.i), [label %if.end22, label %if.end6.i]
  99. if.end6.i: ; preds = %if.end10
  100. indirectbr i8* blockaddress(@nopreheader3, %while.cond2.preheader.i.i), [label %if.then12, label %while.cond2.preheader.i.i]
  101. while.cond2.preheader.i.i: ; preds = %while.end.i18.i, %if.end6.i
  102. indirectbr i8* blockaddress(@nopreheader3, %while.cond2.i.i), [label %while.cond2.i.i]
  103. while.cond2.i.i: ; preds = %while.cond2.i.i, %while.cond2.preheader.i.i
  104. %i1.1.i14.i = phi i32 [ %add.i15.i, %while.cond2.i.i ], [ undef, %while.cond2.preheader.i.i ]
  105. %add.i15.i = add nsw i32 %i1.1.i14.i, undef
  106. indirectbr i8* blockaddress(@nopreheader3, %while.end.i18.i), [label %while.cond2.i.i, label %while.end.i18.i]
  107. while.end.i18.i: ; preds = %while.cond2.i.i
  108. indirectbr i8* blockaddress(@nopreheader3, %while.cond2.preheader.i.i), [label %if.then12, label %while.cond2.preheader.i.i]
  109. if.then12: ; preds = %while.end.i18.i, %if.end6.i
  110. %i1.0.lcssa.i.i = phi i32 [ undef, %if.end6.i ], [ %i1.1.i14.i, %while.end.i18.i ]
  111. indirectbr i8* blockaddress(@nopreheader3, %if.end22), [label %if.end22]
  112. if.end22: ; preds = %if.then12, %if.end10, %entry
  113. ret void
  114. }