diff mbox series

[1/2] rs6000: Fix vsx_le_perm_store_* splitters for !reload_completed

Message ID 6f2e9ff8-53b1-944d-17a3-ec3a2c1aca4d@linux.ibm.com
State New
Headers show
Series [1/2] rs6000: Fix vsx_le_perm_store_* splitters for !reload_completed | expand

Commit Message

Kewen.Lin Aug. 13, 2024, 9:35 a.m. UTC
Hi,

For vsx_le_perm_store_* we have two splitters, one is for
!reload_completed and the other is for reload_completed.
As Richard pointed out in [1], operand 1 here is a pure
input for DF and most passes, but it could be used as the
vector rotation (64 bit) destination of itself, so we
re-compute the source (back to the original value) for
the case reload_completed, while for !reload_completed we
generate one new pseudo, so both cases are fine if operand
1 is still live after this insn.  But according to the
source code, for !reload_completed case, it can logically
reuse the operand 1 as the new pseudo generation is
conditional on can_create_pseudo_p, then it can cause
wrong result once operand 1 is live.  So considering this
and there is no splitting for this when reload_in_progress,
this patch is to fix the code to assert can_create_pseudo_p
there, so that both !reload_completed and reload_completed
cases would ensure operand 1 is unchanged (pure input), it
is also prepared for the following up patch which would
strip the unnecessary INOUT constraint modifier "+".

This also fixes an oversight in the splitter for VSX_LE_128
(!reload_completed), it should use operand 1 rather than
operand 0.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660145.html

Bootstrapped and regtested on powerpc64-linux-gnu P8/P9 and
powerpc64le-linux-gnu P9 and P10.

I'm going to push this next week if no objections.

BR,
Kewen
-----

gcc/ChangeLog:

	* config/rs6000/vsx.md (*vsx_le_perm_store_{<VSX_D:mode>,<VSX_W:mode>,
	v8hi,v16qi,<VSX_LE_128:mode>} !reload_completed splitters): Assert
	can_create_pseudo_p and always generate one new pseudo for operand 1.
---
 gcc/config/rs6000/vsx.md | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

--
2.39.1
diff mbox series

Patch

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 7892477fa92..9c9d2fb2bb4 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -703,8 +703,8 @@  (define_split
       /* Otherwise, fall through to transform into a swapping store.  */
     }

-  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1])
-                                       : operands[1];
+  gcc_assert (can_create_pseudo_p ());
+  operands[2] = gen_reg_rtx_and_attrs (operands[1]);
 })

 ;; The post-reload split requires that we re-permute the source
@@ -775,8 +775,8 @@  (define_split
       /* Otherwise, fall through to transform into a swapping store.  */
     }

-  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1])
-                                       : operands[1];
+  gcc_assert (can_create_pseudo_p ());
+  operands[2] = gen_reg_rtx_and_attrs (operands[1]);
 })

 ;; The post-reload split requires that we re-permute the source
@@ -854,8 +854,8 @@  (define_split
       /* Otherwise, fall through to transform into a swapping store.  */
     }

-  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1])
-                                       : operands[1];
+  gcc_assert (can_create_pseudo_p ());
+  operands[2] = gen_reg_rtx_and_attrs (operands[1]);
 })

 ;; The post-reload split requires that we re-permute the source
@@ -947,8 +947,8 @@  (define_split
       /* Otherwise, fall through to transform into a swapping store.  */
     }

-  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1])
-                                       : operands[1];
+  gcc_assert (can_create_pseudo_p ());
+  operands[2] = gen_reg_rtx_and_attrs (operands[1]);
 })

 ;; The post-reload split requires that we re-permute the source
@@ -1076,9 +1076,8 @@  (define_split
    && !altivec_indexed_or_indirect_operand (operands[0], <MODE>mode)"
   [(const_int 0)]
 {
-  rtx tmp = (can_create_pseudo_p ()
-	     ? gen_reg_rtx_and_attrs (operands[0])
-	     : operands[0]);
+  gcc_assert (can_create_pseudo_p ());
+  rtx tmp = gen_reg_rtx_and_attrs (operands[1]);
   rs6000_emit_le_vsx_permute (tmp, operands[1], <MODE>mode);
   rs6000_emit_le_vsx_permute (operands[0], tmp, <MODE>mode);
   DONE;