unroll-cleanup.ll 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ; PR23524
  2. ; The test is to check redundency produced by loop unroll pass
  3. ; should be cleaned up by later pass.
  4. ; RUN: opt < %s -O2 -S | FileCheck %s
  5. ; After loop unroll:
  6. ; %dec18 = add nsw i32 %dec18.in, -1
  7. ; ...
  8. ; %dec18.1 = add nsw i32 %dec18, -1
  9. ; should be merged to:
  10. ; %dec18.1 = add nsw i32 %dec18.in, -2
  11. ;
  12. ; CHECK-LABEL: @_Z3fn1v(
  13. ; CHECK: %dec18.1 = add nsw i32 %dec18.in, -2
  14. ; ModuleID = '<stdin>'
  15. target triple = "x86_64-unknown-linux-gnu"
  16. @b = global i32 0, align 4
  17. @c = global i32 0, align 4
  18. ; Function Attrs: nounwind uwtable
  19. define void @_Z3fn1v() #0 {
  20. entry:
  21. %tmp = load i32, i32* @b, align 4
  22. %tobool20 = icmp eq i32 %tmp, 0
  23. br i1 %tobool20, label %for.end6, label %for.body.lr.ph
  24. for.body.lr.ph: ; preds = %entry
  25. br label %for.body
  26. for.cond1.for.cond.loopexit_crit_edge: ; preds = %for.inc
  27. %add.ptr.lcssa = phi i16* [ %add.ptr, %for.inc ]
  28. %incdec.ptr.lcssa = phi i8* [ %incdec.ptr, %for.inc ]
  29. br label %for.cond.loopexit
  30. for.cond.loopexit: ; preds = %for.body, %for.cond1.for.cond.loopexit_crit_edge
  31. %r.1.lcssa = phi i16* [ %add.ptr.lcssa, %for.cond1.for.cond.loopexit_crit_edge ], [ %r.022, %for.body ]
  32. %a.1.lcssa = phi i8* [ %incdec.ptr.lcssa, %for.cond1.for.cond.loopexit_crit_edge ], [ %a.021, %for.body ]
  33. %tmp1 = load i32, i32* @b, align 4
  34. %tobool = icmp eq i32 %tmp1, 0
  35. br i1 %tobool, label %for.cond.for.end6_crit_edge, label %for.body
  36. for.body: ; preds = %for.cond.loopexit, %for.body.lr.ph
  37. %r.022 = phi i16* [ undef, %for.body.lr.ph ], [ %r.1.lcssa, %for.cond.loopexit ]
  38. %a.021 = phi i8* [ undef, %for.body.lr.ph ], [ %a.1.lcssa, %for.cond.loopexit ]
  39. %tmp2 = load i32, i32* @c, align 4
  40. %tobool215 = icmp eq i32 %tmp2, 0
  41. br i1 %tobool215, label %for.cond.loopexit, label %for.body3.lr.ph
  42. for.body3.lr.ph: ; preds = %for.body
  43. br label %for.body3
  44. for.body3: ; preds = %for.inc, %for.body3.lr.ph
  45. %dec18.in = phi i32 [ %tmp2, %for.body3.lr.ph ], [ %dec18, %for.inc ]
  46. %r.117 = phi i16* [ %r.022, %for.body3.lr.ph ], [ %add.ptr, %for.inc ]
  47. %a.116 = phi i8* [ %a.021, %for.body3.lr.ph ], [ %incdec.ptr, %for.inc ]
  48. %dec18 = add nsw i32 %dec18.in, -1
  49. %tmp3 = load i8, i8* %a.116, align 1
  50. %cmp = icmp eq i8 %tmp3, 0
  51. br i1 %cmp, label %if.then, label %for.inc
  52. if.then: ; preds = %for.body3
  53. %arrayidx = getelementptr inbounds i16, i16* %r.117, i64 1
  54. store i16 0, i16* %arrayidx, align 2
  55. store i16 0, i16* %r.117, align 2
  56. %arrayidx5 = getelementptr inbounds i16, i16* %r.117, i64 2
  57. store i16 0, i16* %arrayidx5, align 2
  58. br label %for.inc
  59. for.inc: ; preds = %if.then, %for.body3
  60. %incdec.ptr = getelementptr inbounds i8, i8* %a.116, i64 1
  61. %add.ptr = getelementptr inbounds i16, i16* %r.117, i64 3
  62. %tobool2 = icmp eq i32 %dec18, 0
  63. br i1 %tobool2, label %for.cond1.for.cond.loopexit_crit_edge, label %for.body3, !llvm.loop !0
  64. for.cond.for.end6_crit_edge: ; preds = %for.cond.loopexit
  65. br label %for.end6
  66. for.end6: ; preds = %for.cond.for.end6_crit_edge, %entry
  67. ret void
  68. }
  69. !0 = !{!0, !1}
  70. !1 = !{!"llvm.loop.unroll.count", i32 2}