noalias.ll 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ; RUN: opt -scoped-noalias -basicaa -gvn -S < %s | FileCheck %s
  2. define i32 @test1(i32* %p, i32* %q) {
  3. ; CHECK-LABEL: @test1(i32* %p, i32* %q)
  4. ; CHECK: load i32, i32* %p
  5. ; CHECK-NOT: noalias
  6. ; CHECK: %c = add i32 %a, %a
  7. %a = load i32, i32* %p, !noalias !0
  8. %b = load i32, i32* %p
  9. %c = add i32 %a, %b
  10. ret i32 %c
  11. }
  12. define i32 @test2(i32* %p, i32* %q) {
  13. ; CHECK-LABEL: @test2(i32* %p, i32* %q)
  14. ; CHECK: load i32, i32* %p, !alias.scope !0
  15. ; CHECK: %c = add i32 %a, %a
  16. %a = load i32, i32* %p, !alias.scope !0
  17. %b = load i32, i32* %p, !alias.scope !0
  18. %c = add i32 %a, %b
  19. ret i32 %c
  20. }
  21. ; FIXME: In this case we can do better than intersecting the scopes, and can
  22. ; concatenate them instead. Both loads are in the same basic block, the first
  23. ; makes the second safe to speculatively execute, and there are no calls that may
  24. ; throw in between.
  25. define i32 @test3(i32* %p, i32* %q) {
  26. ; CHECK-LABEL: @test3(i32* %p, i32* %q)
  27. ; CHECK: load i32, i32* %p, !alias.scope !1
  28. ; CHECK: %c = add i32 %a, %a
  29. %a = load i32, i32* %p, !alias.scope !1
  30. %b = load i32, i32* %p, !alias.scope !2
  31. %c = add i32 %a, %b
  32. ret i32 %c
  33. }
  34. declare i32 @foo(i32*) readonly
  35. !0 = !{!0}
  36. !1 = !{!1}
  37. !2 = !{!0, !1}