non-local-offset.ll 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
  2. target datalayout = "e-p:64:64:64"
  3. ; GVN should ignore the store to p[1] to see that the load from p[0] is
  4. ; fully redundant.
  5. ; CHECK-LABEL: @yes(
  6. ; CHECK: if.then:
  7. ; CHECK-NEXT: store i32 0, i32* %q
  8. ; CHECK-NEXT: ret void
  9. define void @yes(i1 %c, i32* %p, i32* %q) nounwind {
  10. entry:
  11. store i32 0, i32* %p
  12. %p1 = getelementptr inbounds i32, i32* %p, i64 1
  13. store i32 1, i32* %p1
  14. br i1 %c, label %if.else, label %if.then
  15. if.then:
  16. %t = load i32, i32* %p
  17. store i32 %t, i32* %q
  18. ret void
  19. if.else:
  20. ret void
  21. }
  22. ; GVN should ignore the store to p[1] to see that the first load from p[0] is
  23. ; fully redundant. However, the second load is larger, so it's not a simple
  24. ; redundancy.
  25. ; CHECK-LABEL: @watch_out_for_size_change(
  26. ; CHECK: if.then:
  27. ; CHECK-NEXT: store i32 0, i32* %q
  28. ; CHECK-NEXT: ret void
  29. ; CHECK: if.else:
  30. ; CHECK: load i64, i64* %pc
  31. ; CHECK: store i64
  32. define void @watch_out_for_size_change(i1 %c, i32* %p, i32* %q) nounwind {
  33. entry:
  34. store i32 0, i32* %p
  35. %p1 = getelementptr inbounds i32, i32* %p, i64 1
  36. store i32 1, i32* %p1
  37. br i1 %c, label %if.else, label %if.then
  38. if.then:
  39. %t = load i32, i32* %p
  40. store i32 %t, i32* %q
  41. ret void
  42. if.else:
  43. %pc = bitcast i32* %p to i64*
  44. %qc = bitcast i32* %q to i64*
  45. %t64 = load i64, i64* %pc
  46. store i64 %t64, i64* %qc
  47. ret void
  48. }