basictest.ll 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ; RUN: opt < %s -loop-unswitch -verify-loop-info -S < %s 2>&1 | FileCheck %s
  2. define i32 @test(i32* %A, i1 %C) {
  3. entry:
  4. br label %no_exit
  5. no_exit: ; preds = %no_exit.backedge, %entry
  6. %i.0.0 = phi i32 [ 0, %entry ], [ %i.0.0.be, %no_exit.backedge ] ; <i32> [#uses=3]
  7. %gep.upgrd.1 = zext i32 %i.0.0 to i64 ; <i64> [#uses=1]
  8. %tmp.7 = getelementptr i32, i32* %A, i64 %gep.upgrd.1 ; <i32*> [#uses=4]
  9. %tmp.13 = load i32, i32* %tmp.7 ; <i32> [#uses=2]
  10. %tmp.14 = add i32 %tmp.13, 1 ; <i32> [#uses=1]
  11. store i32 %tmp.14, i32* %tmp.7
  12. br i1 %C, label %then, label %endif
  13. then: ; preds = %no_exit
  14. %tmp.29 = load i32, i32* %tmp.7 ; <i32> [#uses=1]
  15. %tmp.30 = add i32 %tmp.29, 2 ; <i32> [#uses=1]
  16. store i32 %tmp.30, i32* %tmp.7
  17. %inc9 = add i32 %i.0.0, 1 ; <i32> [#uses=2]
  18. %tmp.112 = icmp ult i32 %inc9, 100000 ; <i1> [#uses=1]
  19. br i1 %tmp.112, label %no_exit.backedge, label %return
  20. no_exit.backedge: ; preds = %endif, %then
  21. %i.0.0.be = phi i32 [ %inc9, %then ], [ %inc, %endif ] ; <i32> [#uses=1]
  22. br label %no_exit
  23. endif: ; preds = %no_exit
  24. %inc = add i32 %i.0.0, 1 ; <i32> [#uses=2]
  25. %tmp.1 = icmp ult i32 %inc, 100000 ; <i1> [#uses=1]
  26. br i1 %tmp.1, label %no_exit.backedge, label %return
  27. return: ; preds = %endif, %then
  28. ret i32 %tmp.13
  29. }
  30. ; This simple test would normally unswitch, but should be inhibited by the presence of
  31. ; the noduplicate call.
  32. ; CHECK-LABEL: @test2(
  33. define i32 @test2(i32* %var) {
  34. %mem = alloca i32
  35. store i32 2, i32* %mem
  36. %c = load i32, i32* %mem
  37. br label %loop_begin
  38. loop_begin:
  39. %var_val = load i32, i32* %var
  40. switch i32 %c, label %default [
  41. i32 1, label %inc
  42. i32 2, label %dec
  43. ]
  44. inc:
  45. call void @incf() noreturn nounwind
  46. br label %loop_begin
  47. dec:
  48. ; CHECK: call void @decf()
  49. ; CHECK-NOT: call void @decf()
  50. call void @decf() noreturn nounwind noduplicate
  51. br label %loop_begin
  52. default:
  53. br label %loop_exit
  54. loop_exit:
  55. ret i32 0
  56. ; CHECK: }
  57. }
  58. declare void @incf() noreturn
  59. declare void @decf() noreturn