From: Kewen Lin Date: Wed, 21 Aug 2024 05:26:20 +0000 (-0500) Subject: rs6000: Fix vsx_le_perm_store_* splitters for !reload_completed X-Git-Tag: basepoints/gcc-16~6493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae53e4b99eaad43424f2b0cc1bbabb3b454fb6d8;p=thirdparty%2Fgcc.git rs6000: Fix vsx_le_perm_store_* splitters for !reload_completed 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 gcc/ChangeLog: * config/rs6000/vsx.md (*vsx_le_perm_store_{,, v8hi,v16qi,} !reload_completed splitters): Assert can_create_pseudo_p and always generate one new pseudo for operand 1. --- diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 27069d070e1..89eaef183d9 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -703,8 +703,8 @@ /* 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 @@ /* 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 @@ /* 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 @@ /* 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 @@ && !altivec_indexed_or_indirect_operand (operands[0], 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); rs6000_emit_le_vsx_permute (operands[0], tmp, mode); DONE;