2015-06-17-Metadata.ll 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ;RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s
  2. define i32 @foo(i32 %a, i32 %b) {
  3. ;CHECK-LABEL: foo
  4. entry:
  5. br label %for.body.lr.ph
  6. for.body.lr.ph: ; preds = %entry
  7. %cmp0 = icmp sgt i32 %b, 0
  8. br i1 %cmp0, label %for.body, label %for.cond.cleanup
  9. for.body: ; preds = %for.inc, %for.body.lr.ph
  10. %inc.i = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
  11. %mul.i = phi i32 [ 3, %for.body.lr.ph ], [ %mul.p, %for.inc ]
  12. %add.i = phi i32 [ %a, %for.body.lr.ph ], [ %add.p, %for.inc ]
  13. %cmp1 = icmp eq i32 %a, 12345
  14. br i1 %cmp1, label %if.then, label %if.else, !prof !0
  15. ; CHECK: %cmp1 = icmp eq i32 %a, 12345
  16. ; CHECK-NEXT: br i1 %cmp1, label %if.then.us, label %if.else, !prof !0
  17. if.then: ; preds = %for.body
  18. ; CHECK: if.then.us:
  19. ; CHECK: add nsw i32 %{{.*}}, 123
  20. ; CHECK: %exitcond.us = icmp eq i32 %inc.us, %b
  21. ; CHECK: br i1 %exitcond.us, label %for.cond.cleanup, label %if.then.us
  22. %add = add nsw i32 %add.i, 123
  23. br label %for.inc
  24. if.else: ; preds = %for.body
  25. %mul = mul nsw i32 %mul.i, %b
  26. br label %for.inc
  27. ; CHECK: if.else:
  28. ; CHECK: %mul = mul nsw i32 %mul.i, %b
  29. ; CHECK: %inc = add nuw nsw i32 %inc.i, 1
  30. ; CHECK: %exitcond = icmp eq i32 %inc, %b
  31. ; CHECK: br i1 %exitcond, label %for.cond.cleanup, label %if.else
  32. for.inc: ; preds = %if.then, %if.else
  33. %mul.p = phi i32 [ %b, %if.then ], [ %mul, %if.else ]
  34. %add.p = phi i32 [ %add, %if.then ], [ %a, %if.else ]
  35. %inc = add nuw nsw i32 %inc.i, 1
  36. %exitcond = icmp eq i32 %inc, %b
  37. br i1 %exitcond, label %for.cond.cleanup, label %for.body
  38. for.cond.cleanup: ; preds = %for.inc, %for.body.lr.ph
  39. %t2 = phi i32 [ %b, %for.body.lr.ph ], [ %mul.p, %for.inc ]
  40. %t1 = phi i32 [ %a, %for.body.lr.ph ], [ %add.p, %for.inc ]
  41. %add3 = add nsw i32 %t2, %t1
  42. ret i32 %add3
  43. }
  44. define void @foo_swapped(i32 %a, i32 %b) {
  45. ;CHECK-LABEL: foo_swapped
  46. entry:
  47. br label %for.body
  48. ;CHECK: entry:
  49. ;CHECK-NEXT: %cmp1 = icmp eq i32 1, 2
  50. ;CHECK-NEXT: br i1 %cmp1, label %for.body, label %for.cond.cleanup.split, !prof !1
  51. ;CHECK: for.body:
  52. for.body: ; preds = %for.inc, %entry
  53. %inc.i = phi i32 [ 0, %entry ], [ %inc, %if.then ]
  54. %add.i = phi i32 [ 100, %entry ], [ %add, %if.then ]
  55. %inc = add nuw nsw i32 %inc.i, 1
  56. %cmp1 = icmp eq i32 1, 2
  57. br i1 %cmp1, label %if.then, label %for.cond.cleanup, !prof !0
  58. if.then: ; preds = %for.body
  59. %add = add nsw i32 %a, %add.i
  60. %exitcond = icmp eq i32 %inc, %b
  61. br i1 %exitcond, label %for.cond.cleanup, label %for.body
  62. for.cond.cleanup: ; preds = %for.inc, %for.body.lr.ph, %for.body
  63. ret void
  64. }
  65. !0 = !{!"branch_weights", i32 64, i32 4}
  66. ;CHECK: !0 = !{!"branch_weights", i32 64, i32 4}
  67. ;CHECK: !1 = !{!"branch_weights", i32 4, i32 64}