SolveQuadraticEquation.ll 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ; RUN: opt < %s -analyze -scalar-evolution -scalar-evolution-max-iterations=0 | FileCheck %s
  2. ; PR1101
  3. @A = weak global [1000 x i32] zeroinitializer, align 32
  4. define void @test1(i32 %N) {
  5. entry:
  6. %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
  7. br label %bb3
  8. bb: ; preds = %bb3
  9. %tmp = getelementptr [1000 x i32], [1000 x i32]* @A, i32 0, i32 %i.0 ; <i32*> [#uses=1]
  10. store i32 123, i32* %tmp
  11. %tmp2 = add i32 %i.0, 1 ; <i32> [#uses=1]
  12. br label %bb3
  13. bb3: ; preds = %bb, %entry
  14. %i.0 = phi i32 [ 2, %entry ], [ %tmp2, %bb ] ; <i32> [#uses=3]
  15. %SQ = mul i32 %i.0, %i.0
  16. %tmp4 = mul i32 %i.0, 2
  17. %tmp5 = sub i32 %SQ, %tmp4
  18. %tmp3 = icmp sle i32 %tmp5, 9999 ; <i1> [#uses=1]
  19. br i1 %tmp3, label %bb, label %bb5
  20. bb5: ; preds = %bb3
  21. br label %return
  22. return: ; preds = %bb5
  23. ret void
  24. }
  25. ; CHECK: Determining loop execution counts for: @test1
  26. ; CHECK-NEXT: backedge-taken count is 100
  27. ; PR10383
  28. ; These next two used to crash.
  29. define void @test2(i1 %cmp, i64 %n) {
  30. entry:
  31. br label %for.body1
  32. for.body1:
  33. %a0.08 = phi i64 [ 0, %entry ], [ %inc512, %for.body1 ]
  34. %inc512 = add i64 %a0.08, 1
  35. br i1 %cmp, label %preheader, label %for.body1
  36. preheader:
  37. br label %for.body2
  38. for.body2:
  39. %indvar = phi i64 [ 0, %preheader ], [ %indvar.next, %for.body2 ]
  40. %tmp111 = add i64 %n, %indvar
  41. %tmp114 = mul i64 %a0.08, %indvar
  42. %mul542 = mul i64 %tmp114, %tmp111
  43. %indvar.next = add i64 %indvar, 1
  44. br i1 undef, label %end, label %for.body2
  45. end:
  46. ret void
  47. }
  48. ; CHECK: Determining loop execution counts for: @test2
  49. define i32 @test3() {
  50. if.then466:
  51. br i1 undef, label %for.cond539.preheader, label %for.inc479
  52. for.inc479:
  53. %a2.07 = phi i32 [ %add495, %for.inc479 ], [ 0, %if.then466 ]
  54. %j.36 = phi i32 [ %inc497, %for.inc479 ], [ undef, %if.then466 ]
  55. %mul484 = mul nsw i32 %j.36, %j.36
  56. %mul491 = mul i32 %j.36, %j.36
  57. %mul493 = mul i32 %mul491, %mul484
  58. %add495 = add nsw i32 %mul493, %a2.07
  59. %inc497 = add nsw i32 %j.36, 1
  60. br i1 undef, label %for.cond539.preheader, label %for.inc479
  61. for.cond539.preheader:
  62. unreachable
  63. }
  64. ; CHECK: Determining loop execution counts for: @test3
  65. ; PR13489
  66. ; We used to crash on this too.
  67. define void @test4() {
  68. entry:
  69. br label %for.body
  70. for.body: ; preds = %for.body, %entry
  71. %v2.02 = phi i64 [ 2, %entry ], [ %phitmp, %for.body ]
  72. %v1.01 = phi i64 [ -2, %entry ], [ %sub1, %for.body ]
  73. %sub1 = sub i64 %v1.01, %v2.02
  74. %phitmp = add i64 %v2.02, 2
  75. %tobool = icmp eq i64 %sub1, %phitmp
  76. br i1 %tobool, label %for.end, label %for.body
  77. for.end: ; preds = %for.body
  78. ret void
  79. }
  80. ; CHECK: Determining loop execution counts for: @test4