past-the-end.ll 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ; RUN: opt < %s -instsimplify -S | FileCheck %s
  2. target datalayout = "p:32:32"
  3. ; Check some past-the-end subtleties.
  4. @opte_a = global i32 0
  5. @opte_b = global i32 0
  6. ; Comparing base addresses of two distinct globals. Never equal.
  7. define zeroext i1 @no_offsets() {
  8. %t = icmp eq i32* @opte_a, @opte_b
  9. ret i1 %t
  10. ; CHECK: no_offsets(
  11. ; CHECK: ret i1 false
  12. }
  13. ; Comparing past-the-end addresses of two distinct globals. Never equal.
  14. define zeroext i1 @both_past_the_end() {
  15. %x = getelementptr i32, i32* @opte_a, i32 1
  16. %y = getelementptr i32, i32* @opte_b, i32 1
  17. %t = icmp eq i32* %x, %y
  18. ret i1 %t
  19. ; CHECK: both_past_the_end(
  20. ; CHECK-NOT: ret i1 true
  21. ; TODO: refine this
  22. }
  23. ; Comparing past-the-end addresses of one global to the base address
  24. ; of another. Can't fold this.
  25. define zeroext i1 @just_one_past_the_end() {
  26. %x = getelementptr i32, i32* @opte_a, i32 1
  27. %t = icmp eq i32* %x, @opte_b
  28. ret i1 %t
  29. ; CHECK: just_one_past_the_end(
  30. ; CHECK: ret i1 icmp eq (i32* getelementptr inbounds (i32, i32* @opte_a, i32 1), i32* @opte_b)
  31. }
  32. ; Comparing base addresses of two distinct allocas. Never equal.
  33. define zeroext i1 @no_alloca_offsets() {
  34. %m = alloca i32
  35. %n = alloca i32
  36. %t = icmp eq i32* %m, %n
  37. ret i1 %t
  38. ; CHECK: no_alloca_offsets(
  39. ; CHECK: ret i1 false
  40. }
  41. ; Comparing past-the-end addresses of two distinct allocas. Never equal.
  42. define zeroext i1 @both_past_the_end_alloca() {
  43. %m = alloca i32
  44. %n = alloca i32
  45. %x = getelementptr i32, i32* %m, i32 1
  46. %y = getelementptr i32, i32* %n, i32 1
  47. %t = icmp eq i32* %x, %y
  48. ret i1 %t
  49. ; CHECK: both_past_the_end_alloca(
  50. ; CHECK-NOT: ret i1 true
  51. ; TODO: refine this
  52. }
  53. ; Comparing past-the-end addresses of one alloca to the base address
  54. ; of another. Can't fold this.
  55. define zeroext i1 @just_one_past_the_end_alloca() {
  56. %m = alloca i32
  57. %n = alloca i32
  58. %x = getelementptr i32, i32* %m, i32 1
  59. %t = icmp eq i32* %x, %n
  60. ret i1 %t
  61. ; CHECK: just_one_past_the_end_alloca(
  62. ; CHECK: ret i1 %t
  63. }