nested_loop_with_branches.ll 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ; RUN: opt < %s -analyze -block-freq | FileCheck %s
  2. ; CHECK-LABEL: Printing analysis {{.*}} for function 'nested_loop_with_branches'
  3. ; CHECK-NEXT: block-frequency-info: nested_loop_with_branches
  4. define void @nested_loop_with_branches(i32 %a) {
  5. ; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
  6. entry:
  7. %v0 = call i1 @foo0(i32 %a)
  8. br i1 %v0, label %exit, label %outer, !prof !0
  9. ; CHECK-NEXT: outer: float = 12.0,
  10. outer:
  11. %i = phi i32 [ 0, %entry ], [ %i.next, %inner.end ], [ %i.next, %no_inner ]
  12. %i.next = add i32 %i, 1
  13. %do_inner = call i1 @foo1(i32 %i)
  14. br i1 %do_inner, label %no_inner, label %inner, !prof !0
  15. ; CHECK-NEXT: inner: float = 36.0,
  16. inner:
  17. %j = phi i32 [ 0, %outer ], [ %j.next, %inner.end ]
  18. %side = call i1 @foo3(i32 %j)
  19. br i1 %side, label %left, label %right, !prof !0
  20. ; CHECK-NEXT: left: float = 9.0,
  21. left:
  22. %v4 = call i1 @foo4(i32 %j)
  23. br label %inner.end
  24. ; CHECK-NEXT: right: float = 27.0,
  25. right:
  26. %v5 = call i1 @foo5(i32 %j)
  27. br label %inner.end
  28. ; CHECK-NEXT: inner.end: float = 36.0,
  29. inner.end:
  30. %stay_inner = phi i1 [ %v4, %left ], [ %v5, %right ]
  31. %j.next = add i32 %j, 1
  32. br i1 %stay_inner, label %inner, label %outer, !prof !1
  33. ; CHECK-NEXT: no_inner: float = 3.0,
  34. no_inner:
  35. %continue = call i1 @foo6(i32 %i)
  36. br i1 %continue, label %outer, label %exit, !prof !1
  37. ; CHECK-NEXT: exit: float = 1.0, int = [[ENTRY]]
  38. exit:
  39. ret void
  40. }
  41. declare i1 @foo0(i32)
  42. declare i1 @foo1(i32)
  43. declare i1 @foo2(i32)
  44. declare i1 @foo3(i32)
  45. declare i1 @foo4(i32)
  46. declare i1 @foo5(i32)
  47. declare i1 @foo6(i32)
  48. !0 = !{!"branch_weights", i32 1, i32 3}
  49. !1 = !{!"branch_weights", i32 3, i32 1}