phi.ll 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ; RUN: opt -S -consthoist < %s | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx10.9.0"
  4. ; PR18626
  5. define i8* @test1(i1 %cmp, i64* %tmp) {
  6. entry:
  7. call void @foo(i8* inttoptr (i64 68719476735 to i8*))
  8. br i1 %cmp, label %if.end, label %return
  9. if.end: ; preds = %bb1
  10. call void @foo(i8* inttoptr (i64 68719476736 to i8*))
  11. br label %return
  12. return:
  13. %retval.0 = phi i8* [ null, %entry ], [ inttoptr (i64 68719476736 to i8*), %if.end ]
  14. store i64 1172321806, i64* %tmp
  15. ret i8* %retval.0
  16. ; CHECK-LABEL: @test1
  17. ; CHECK: if.end:
  18. ; CHECK: %2 = inttoptr i64 %const to i8*
  19. ; CHECK-NEXT: br
  20. ; CHECK: return:
  21. ; CHECK-NEXT: %retval.0 = phi i8* [ null, %entry ], [ %2, %if.end ]
  22. }
  23. define void @test2(i1 %cmp, i64** %tmp) {
  24. entry:
  25. call void @foo(i8* inttoptr (i64 68719476736 to i8*))
  26. br i1 %cmp, label %if.end, label %return
  27. if.end: ; preds = %bb1
  28. call void @foo(i8* inttoptr (i64 68719476736 to i8*))
  29. br label %return
  30. return:
  31. store i64* inttoptr (i64 68719476735 to i64*), i64** %tmp
  32. ret void
  33. ; CHECK-LABEL: @test2
  34. ; CHECK: return:
  35. ; CHECK-NEXT: %const_mat = add i64 %const, -1
  36. ; CHECK-NEXT: inttoptr i64 %const_mat to i64*
  37. }
  38. declare void @foo(i8*)
  39. ; PR18768
  40. define i32 @test3(i1 %c) {
  41. entry:
  42. br i1 %c, label %if.then, label %if.end3
  43. if.then: ; preds = %entry
  44. br label %if.end3
  45. if.end3: ; preds = %if.then, %entry
  46. %d.0 = phi i32* [ inttoptr (i64 985162435264511 to i32*), %entry ], [ null, %if.then ]
  47. %cmp4 = icmp eq i32* %d.0, inttoptr (i64 985162435264511 to i32*)
  48. %cmp6 = icmp eq i32* %d.0, inttoptr (i64 985162418487296 to i32*)
  49. %or = or i1 %cmp4, %cmp6
  50. br i1 %or, label %if.then8, label %if.end9
  51. if.then8: ; preds = %if.end3
  52. ret i32 1
  53. if.end9: ; preds = %if.then8, %if.end3
  54. ret i32 undef
  55. }
  56. ; <rdar://problem/16394449>
  57. define i64 @switch_test1(i64 %a) {
  58. ; CHECK-LABEL: @switch_test1
  59. ; CHECK: %0 = phi i64 [ %const, %case2 ], [ %const_mat, %Entry ], [ %const_mat, %Entry ]
  60. Entry:
  61. %sel = add i64 %a, 4519019440
  62. switch i64 %sel, label %fail [
  63. i64 462, label %continuation
  64. i64 449, label %case2
  65. i64 443, label %continuation
  66. ]
  67. case2:
  68. br label %continuation
  69. continuation:
  70. %0 = phi i64 [ 4519019440, %case2 ], [ 4519019460, %Entry ], [ 4519019460, %Entry ]
  71. ret i64 0;
  72. fail:
  73. ret i64 -1;
  74. }
  75. define i64 @switch_test2(i64 %a) {
  76. ; CHECK-LABEL: @switch_test2
  77. ; CHECK: %2 = phi i64* [ %1, %case2 ], [ %0, %Entry ], [ %0, %Entry ]
  78. Entry:
  79. %sel = add i64 %a, 4519019440
  80. switch i64 %sel, label %fail [
  81. i64 462, label %continuation
  82. i64 449, label %case2
  83. i64 443, label %continuation
  84. ]
  85. case2:
  86. br label %continuation
  87. continuation:
  88. %0 = phi i64* [ inttoptr(i64 4519019440 to i64*), %case2 ], [ inttoptr(i64 4519019460 to i64*), %Entry ], [ inttoptr(i64 4519019460 to i64*), %Entry ]
  89. ret i64 0;
  90. fail:
  91. ret i64 -1;
  92. }