branch-fold.ll 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ; RUN: opt < %s -simplifycfg -S | FileCheck %s
  2. define void @test(i32* %P, i32* %Q, i1 %A, i1 %B) {
  3. ; CHECK: test
  4. ; CHECK: br i1
  5. ; CHECK-NOT: br i1
  6. ; CHECK: ret
  7. ; CHECK: ret
  8. entry:
  9. br i1 %A, label %a, label %b
  10. a:
  11. br i1 %B, label %b, label %c
  12. b:
  13. store i32 123, i32* %P
  14. ret void
  15. c:
  16. ret void
  17. }
  18. ; rdar://10554090
  19. define zeroext i1 @test2(i64 %i0, i64 %i1) nounwind uwtable readonly ssp {
  20. entry:
  21. ; CHECK: test2
  22. ; CHECK: br i1
  23. %and.i.i = and i64 %i0, 281474976710655
  24. %and.i11.i = and i64 %i1, 281474976710655
  25. %or.cond = icmp eq i64 %and.i.i, %and.i11.i
  26. br i1 %or.cond, label %c, label %a
  27. a:
  28. ; CHECK: br
  29. %shr.i4.i = lshr i64 %i0, 48
  30. %and.i5.i = and i64 %shr.i4.i, 32767
  31. %shr.i.i = lshr i64 %i1, 48
  32. %and.i2.i = and i64 %shr.i.i, 32767
  33. %cmp9.i = icmp ult i64 %and.i5.i, %and.i2.i
  34. br i1 %cmp9.i, label %c, label %b
  35. b:
  36. ; CHECK-NOT: br
  37. %shr.i13.i9 = lshr i64 %i1, 48
  38. %and.i14.i10 = and i64 %shr.i13.i9, 32767
  39. %shr.i.i11 = lshr i64 %i0, 48
  40. %and.i11.i12 = and i64 %shr.i.i11, 32767
  41. %phitmp = icmp uge i64 %and.i14.i10, %and.i11.i12
  42. br label %c
  43. c:
  44. %o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ]
  45. ret i1 %o2
  46. }
  47. ; PR13180
  48. define void @pr13180(i8 %p) {
  49. entry:
  50. %tobool = icmp eq i8 %p, 0
  51. br i1 %tobool, label %cond.false, label %cond.true
  52. cond.true: ; preds = %entry
  53. br label %cond.end
  54. cond.false: ; preds = %entry
  55. %phitmp = icmp eq i8 %p, 0
  56. br label %cond.end
  57. cond.end: ; preds = %cond.false, %cond.true
  58. %cond = phi i1 [ undef, %cond.true ], [ %phitmp, %cond.false ]
  59. unreachable
  60. }