phi-undef-loadstore.ll 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ; RUN: opt -simplifycfg -S < %s | FileCheck %s
  2. declare void @bar() nounwind
  3. define i32 @test1(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
  4. entry:
  5. %tobool = icmp eq i32 %b, 0
  6. br i1 %tobool, label %if.else, label %if.then
  7. if.then: ; preds = %entry
  8. tail call void @bar() nounwind
  9. br label %if.end7
  10. if.else: ; preds = %entry
  11. %tobool3 = icmp eq i32 %d, 0
  12. br i1 %tobool3, label %if.end7, label %if.then4
  13. if.then4: ; preds = %if.else
  14. tail call void @bar() nounwind
  15. br label %if.end7
  16. if.end7: ; preds = %if.else, %if.then4, %if.then
  17. %x.0 = phi i32* [ %a, %if.then ], [ %c, %if.then4 ], [ null, %if.else ]
  18. %tmp9 = load i32, i32* %x.0
  19. ret i32 %tmp9
  20. ; CHECK-LABEL: @test1(
  21. ; CHECK: if.else:
  22. ; CHECK: br label %if.end7
  23. ; CHECK: phi i32* [ %a, %if.then ], [ %c, %if.else ]
  24. }
  25. define i32 @test2(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
  26. entry:
  27. %tobool = icmp eq i32 %b, 0
  28. br i1 %tobool, label %if.else, label %if.then
  29. if.then: ; preds = %entry
  30. tail call void @bar() nounwind
  31. br label %if.end7
  32. if.else: ; preds = %entry
  33. %tobool3 = icmp eq i32 %d, 0
  34. br i1 %tobool3, label %if.end7, label %if.then4
  35. if.then4: ; preds = %if.else
  36. tail call void @bar() nounwind
  37. br label %if.end7
  38. if.end7: ; preds = %if.else, %if.then4, %if.then
  39. %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
  40. %tmp9 = load i32, i32* %x.0
  41. ret i32 %tmp9
  42. ; CHECK-LABEL: @test2(
  43. ; CHECK: if.else:
  44. ; CHECK: unreachable
  45. ; CHECK-NOT: phi
  46. }
  47. define i32 @test3(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
  48. entry:
  49. %tobool = icmp eq i32 %b, 0
  50. br i1 %tobool, label %if.else, label %if.then
  51. if.then: ; preds = %entry
  52. tail call void @bar() nounwind
  53. br label %if.end7
  54. if.else: ; preds = %entry
  55. %tobool3 = icmp eq i32 %d, 0
  56. br i1 %tobool3, label %if.end7, label %if.then4
  57. if.then4: ; preds = %if.else
  58. tail call void @bar() nounwind
  59. br label %if.end7
  60. if.end7: ; preds = %if.else, %if.then4, %if.then
  61. %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
  62. tail call void @bar() nounwind
  63. %tmp9 = load i32, i32* %x.0
  64. ret i32 %tmp9
  65. ; CHECK-LABEL: @test3(
  66. ; CHECK: if.end7:
  67. ; CHECK: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
  68. }
  69. define i32 @test4(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
  70. entry:
  71. %tobool = icmp eq i32 %b, 0
  72. br i1 %tobool, label %if.else, label %if.then
  73. if.then: ; preds = %entry
  74. tail call void @bar() nounwind
  75. br label %if.end7
  76. if.else: ; preds = %entry
  77. %tobool3 = icmp eq i32 %d, 0
  78. br i1 %tobool3, label %if.end7, label %if.then4
  79. if.then4: ; preds = %if.else
  80. tail call void @bar() nounwind
  81. br label %if.end7
  82. if.end7: ; preds = %if.else, %if.then4, %if.then
  83. %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
  84. %gep = getelementptr i32, i32* %x.0, i32 10
  85. %tmp9 = load i32, i32* %gep
  86. %tmp10 = or i32 %tmp9, 1
  87. store i32 %tmp10, i32* %gep
  88. ret i32 %tmp9
  89. ; CHECK-LABEL: @test4(
  90. ; CHECK-NOT: phi
  91. }