dse.ll 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ; RUN: opt < %s -tbaa -basicaa -dse -S | FileCheck %s
  2. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  3. ; DSE should make use of TBAA.
  4. ; CHECK: @test0_yes
  5. ; CHECK-NEXT: load i8, i8* %b
  6. ; CHECK-NEXT: store i8 1, i8* %a
  7. ; CHECK-NEXT: ret i8 %y
  8. define i8 @test0_yes(i8* %a, i8* %b) nounwind {
  9. store i8 0, i8* %a, !tbaa !1
  10. %y = load i8, i8* %b, !tbaa !2
  11. store i8 1, i8* %a, !tbaa !1
  12. ret i8 %y
  13. }
  14. ; CHECK: @test0_no
  15. ; CHECK-NEXT: store i8 0, i8* %a
  16. ; CHECK-NEXT: load i8, i8* %b
  17. ; CHECK-NEXT: store i8 1, i8* %a
  18. ; CHECK-NEXT: ret i8 %y
  19. define i8 @test0_no(i8* %a, i8* %b) nounwind {
  20. store i8 0, i8* %a, !tbaa !3
  21. %y = load i8, i8* %b, !tbaa !4
  22. store i8 1, i8* %a, !tbaa !3
  23. ret i8 %y
  24. }
  25. ; CHECK: @test1_yes
  26. ; CHECK-NEXT: load i8, i8* %b
  27. ; CHECK-NEXT: store i8 1, i8* %a
  28. ; CHECK-NEXT: ret i8 %y
  29. define i8 @test1_yes(i8* %a, i8* %b) nounwind {
  30. store i8 0, i8* %a
  31. %y = load i8, i8* %b, !tbaa !5
  32. store i8 1, i8* %a
  33. ret i8 %y
  34. }
  35. ; CHECK: @test1_no
  36. ; CHECK-NEXT: store i8 0, i8* %a
  37. ; CHECK-NEXT: load i8, i8* %b
  38. ; CHECK-NEXT: store i8 1, i8* %a
  39. ; CHECK-NEXT: ret i8 %y
  40. define i8 @test1_no(i8* %a, i8* %b) nounwind {
  41. store i8 0, i8* %a
  42. %y = load i8, i8* %b, !tbaa !6
  43. store i8 1, i8* %a
  44. ret i8 %y
  45. }
  46. ; Root note.
  47. !0 = !{ }
  48. ; Some type.
  49. !1 = !{!7, !7, i64 0}
  50. ; Some other non-aliasing type.
  51. !2 = !{!8, !8, i64 0}
  52. ; Some type.
  53. !3 = !{!9, !9, i64 0}
  54. ; Some type in a different type system.
  55. !4 = !{!10, !10, i64 0}
  56. ; Invariant memory.
  57. !5 = !{!11, !11, i64 0, i1 1}
  58. ; Not invariant memory.
  59. !6 = !{!11, !11, i64 0, i1 0}
  60. !7 = !{ !"foo", !0 }
  61. !8 = !{ !"bar", !0 }
  62. !9 = !{ !"foo", !0 }
  63. !10 = !{ !"bar", !"different" }
  64. !11 = !{ !"qux", !0}