0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. From adb60dc78e0da4877747f32347cee339364775be Mon Sep 17 00:00:00 2001
  2. From: Richard Sandiford <richard.sandiford@arm.com>
  3. Date: Fri, 15 Sep 2023 09:19:14 +0100
  4. Subject: [PATCH] aarch64: Fix loose ldpstp check [PR111411]
  5. aarch64_operands_ok_for_ldpstp contained the code:
  6. /* One of the memory accesses must be a mempair operand.
  7. If it is not the first one, they need to be swapped by the
  8. peephole. */
  9. if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
  10. && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
  11. return false;
  12. But the requirement isn't just that one of the accesses must be a
  13. valid mempair operand. It's that the lower access must be, since
  14. that's the access that will be used for the instruction operand.
  15. gcc/
  16. PR target/111411
  17. * config/aarch64/aarch64.cc (aarch64_operands_ok_for_ldpstp): Require
  18. the lower memory access to a mem-pair operand.
  19. gcc/testsuite/
  20. PR target/111411
  21. * gcc.dg/rtl/aarch64/pr111411.c: New test.
  22. Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=2d38f45bcca62ca0c7afef4b579f82c5c2a01610]
  23. Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
  24. ---
  25. gcc/config/aarch64/aarch64.cc | 8 ++-
  26. gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c | 57 +++++++++++++++++++++
  27. 2 files changed, 60 insertions(+), 5 deletions(-)
  28. create mode 100644 gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
  29. diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
  30. index 6118a3354ac..9b1f791ca8b 100644
  31. --- a/gcc/config/aarch64/aarch64.cc
  32. +++ b/gcc/config/aarch64/aarch64.cc
  33. @@ -26154,11 +26154,9 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load,
  34. gcc_assert (known_eq (GET_MODE_SIZE (GET_MODE (mem_1)),
  35. GET_MODE_SIZE (GET_MODE (mem_2))));
  36. - /* One of the memory accesses must be a mempair operand.
  37. - If it is not the first one, they need to be swapped by the
  38. - peephole. */
  39. - if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
  40. - && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
  41. + /* The lower memory access must be a mem-pair operand. */
  42. + rtx lower_mem = reversed ? mem_2 : mem_1;
  43. + if (!aarch64_mem_pair_operand (lower_mem, GET_MODE (lower_mem)))
  44. return false;
  45. if (REG_P (reg_1) && FP_REGNUM_P (REGNO (reg_1)))
  46. diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c b/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
  47. new file mode 100644
  48. index 00000000000..ad07e9c6c89
  49. --- /dev/null
  50. +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
  51. @@ -0,0 +1,57 @@
  52. +/* { dg-do compile { target aarch64*-*-* } } */
  53. +/* { dg-require-effective-target lp64 } */
  54. +/* { dg-options "-O -fdisable-rtl-postreload -fpeephole2 -fno-schedule-fusion" } */
  55. +
  56. +extern int data[];
  57. +
  58. +void __RTL (startwith ("ira")) foo (void *ptr)
  59. +{
  60. + (function "foo"
  61. + (param "ptr"
  62. + (DECL_RTL (reg/v:DI <0> [ ptr ]))
  63. + (DECL_RTL_INCOMING (reg/v:DI x0 [ ptr ]))
  64. + ) ;; param "ptr"
  65. + (insn-chain
  66. + (block 2
  67. + (edge-from entry (flags "FALLTHRU"))
  68. + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
  69. + (insn 4 (set (reg:DI <0>) (reg:DI x0)))
  70. + (insn 5 (set (reg:DI <1>)
  71. + (plus:DI (reg:DI <0>) (const_int 768))))
  72. + (insn 6 (set (mem:SI (plus:DI (reg:DI <0>)
  73. + (const_int 508)) [1 &data+508 S4 A4])
  74. + (const_int 0)))
  75. + (insn 7 (set (mem:SI (plus:DI (reg:DI <1>)
  76. + (const_int -256)) [1 &data+512 S4 A4])
  77. + (const_int 0)))
  78. + (edge-to exit (flags "FALLTHRU"))
  79. + ) ;; block 2
  80. + ) ;; insn-chain
  81. + ) ;; function
  82. +}
  83. +
  84. +void __RTL (startwith ("ira")) bar (void *ptr)
  85. +{
  86. + (function "bar"
  87. + (param "ptr"
  88. + (DECL_RTL (reg/v:DI <0> [ ptr ]))
  89. + (DECL_RTL_INCOMING (reg/v:DI x0 [ ptr ]))
  90. + ) ;; param "ptr"
  91. + (insn-chain
  92. + (block 2
  93. + (edge-from entry (flags "FALLTHRU"))
  94. + (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
  95. + (insn 4 (set (reg:DI <0>) (reg:DI x0)))
  96. + (insn 5 (set (reg:DI <1>)
  97. + (plus:DI (reg:DI <0>) (const_int 768))))
  98. + (insn 6 (set (mem:SI (plus:DI (reg:DI <1>)
  99. + (const_int -256)) [1 &data+512 S4 A4])
  100. + (const_int 0)))
  101. + (insn 7 (set (mem:SI (plus:DI (reg:DI <0>)
  102. + (const_int 508)) [1 &data+508 S4 A4])
  103. + (const_int 0)))
  104. + (edge-to exit (flags "FALLTHRU"))
  105. + ) ;; block 2
  106. + ) ;; insn-chain
  107. + ) ;; function
  108. +}