2011-11-18-TwoSwitches-Threshold.ll 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ; REQUIRES: asserts
  2. ; RUN: opt -loop-unswitch -loop-unswitch-threshold 13 -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
  3. ; RUN: opt -S -loop-unswitch -loop-unswitch-threshold 13 -verify-loop-info -verify-dom-info < %s | FileCheck %s
  4. ; STATS: 1 loop-simplify - Number of pre-header or exit blocks inserted
  5. ; STATS: 1 loop-unswitch - Number of switches unswitched
  6. ; ModuleID = '../llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll'
  7. ; CHECK: %1 = icmp eq i32 %c, 1
  8. ; CHECK-NEXT: br i1 %1, label %.split.us, label %..split_crit_edge
  9. ; CHECK: ..split_crit_edge: ; preds = %0
  10. ; CHECK-NEXT: br label %.split
  11. ; CHECK: .split.us: ; preds = %0
  12. ; CHECK-NEXT: br label %loop_begin.us
  13. ; CHECK: loop_begin.us: ; preds = %loop_begin.backedge.us, %.split.us
  14. ; CHECK: switch i32 1, label %second_switch.us [
  15. ; CHECK-NEXT: i32 1, label %inc.us
  16. ; CHECK: second_switch.us: ; preds = %loop_begin.us
  17. ; CHECK-NEXT: switch i32 %d, label %default.us [
  18. ; CHECK-NEXT: i32 1, label %inc.us
  19. ; CHECK-NEXT: ]
  20. ; CHECK: inc.us: ; preds = %second_switch.us, %loop_begin.us
  21. ; CHECK-NEXT: call void @incf() [[NOR_NUW:#[0-9]+]]
  22. ; CHECK-NEXT: br label %loop_begin.backedge.us
  23. ; CHECK: .split: ; preds = %..split_crit_edge
  24. ; CHECK-NEXT: br label %loop_begin
  25. ; CHECK: loop_begin: ; preds = %loop_begin.backedge, %.split
  26. ; CHECK: switch i32 %c, label %second_switch [
  27. ; CHECK-NEXT: i32 1, label %loop_begin.inc_crit_edge
  28. ; CHECK-NEXT: ]
  29. ; CHECK: loop_begin.inc_crit_edge: ; preds = %loop_begin
  30. ; CHECK-NEXT: br i1 true, label %us-unreachable, label %inc
  31. ; CHECK: second_switch: ; preds = %loop_begin
  32. ; CHECK-NEXT: switch i32 %d, label %default [
  33. ; CHECK-NEXT: i32 1, label %inc
  34. ; CHECK-NEXT: ]
  35. ; CHECK: inc: ; preds = %loop_begin.inc_crit_edge, %second_switch
  36. ; CHECK-NEXT: call void @incf() [[NOR_NUW]]
  37. ; CHECK-NEXT: br label %loop_begin.backedge
  38. define i32 @test(i32* %var) {
  39. %mem = alloca i32
  40. store i32 2, i32* %mem
  41. %c = load i32, i32* %mem
  42. %d = load i32, i32* %mem
  43. br label %loop_begin
  44. loop_begin:
  45. %var_val = load i32, i32* %var
  46. switch i32 %c, label %second_switch [
  47. i32 1, label %inc
  48. ]
  49. second_switch:
  50. switch i32 %d, label %default [
  51. i32 1, label %inc
  52. ]
  53. inc:
  54. call void @incf() noreturn nounwind
  55. br label %loop_begin
  56. default:
  57. br label %loop_begin
  58. loop_exit:
  59. ret i32 0
  60. }
  61. declare void @incf() noreturn
  62. declare void @decf() noreturn
  63. ; CHECK: attributes #0 = { noreturn }
  64. ; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind }