Hi, For stack_tie, currently below insn is generated: (insn 15 14 16 3 (parallel [ (set (mem/c:BLK (reg/f:DI 1 1) [1 A8]) (const_int 0 [0])) ]) "/home/guojiufu/temp/gdb.c":13:3 922 {stack_tie} (nil))
It is "set (mem/c:BLK (reg/f:DI 1 1) (const_int 0 [0])". This maybe looks like "a memory block is zerored", while actually stack_tie may be more like a placeholder, and does not generate any thing. To avoid potential misunderstand, "UNPSEC:BLK [(const_int 0)].." could be used here. Compare with previous version, this addes ChangeLog and removes const_anchor parts. https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621356.html. Bootstrap®test pass on ppc64{,le}. Is this ok for trunk? BR, Jeff (Jiufu Guo) gcc/ChangeLog: * config/rs6000/predicates.md (tie_operand): Update to match new stack_tie pattern. * config/rs6000/rs6000-logue.cc (rs6000_emit_stack_tie): Update to use the new stack_tie pattern. * config/rs6000/rs6000.md (UNSPEC_TIE): New UNSPEC. (restore_stack_block): Update to use the new stack_tie pattern. (restore_stack_nonlocal): Likewise. (stack_tie): Update pattern to use UNSPEC_TIE. (stack_restore_tie): Likewise. --- gcc/config/rs6000/predicates.md | 11 +++++++---- gcc/config/rs6000/rs6000-logue.cc | 4 +++- gcc/config/rs6000/rs6000.md | 14 ++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index a16ee30f0c0..4748cb37ce8 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -1854,10 +1854,13 @@ (define_predicate "stmw_operation" (define_predicate "tie_operand" (match_code "parallel") { - return (GET_CODE (XVECEXP (op, 0, 0)) == SET - && MEM_P (XEXP (XVECEXP (op, 0, 0), 0)) - && GET_MODE (XEXP (XVECEXP (op, 0, 0), 0)) == BLKmode - && XEXP (XVECEXP (op, 0, 0), 1) == const0_rtx); + rtx set = XVECEXP (op, 0, 0); + return (GET_CODE (set) == SET + && MEM_P (SET_DEST (set)) + && GET_MODE (SET_DEST (set)) == BLKmode + && GET_CODE (SET_SRC (set)) == UNSPEC + && XINT (SET_SRC (set), 1) == UNSPEC_TIE + && XVECEXP (SET_SRC (set), 0, 0) == const0_rtx); }) ;; Match a small code model toc reference (or medium and large diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index bc6b153b59f..b99f43a8282 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -1463,7 +1463,9 @@ rs6000_emit_stack_tie (rtx fp, bool hard_frame_needed) while (--i >= 0) { rtx mem = gen_frame_mem (BLKmode, regs[i]); - RTVEC_ELT (p, i) = gen_rtx_SET (mem, const0_rtx); + RTVEC_ELT (p, i) + = gen_rtx_SET (mem, gen_rtx_UNSPEC (BLKmode, gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); } emit_insn (gen_stack_tie (gen_rtx_PARALLEL (VOIDmode, p))); diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index b0db8ae508d..fdcf8347812 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -158,6 +158,7 @@ (define_c_enum "unspec" UNSPEC_HASHCHK UNSPEC_XXSPLTIDP_CONST UNSPEC_XXSPLTIW_CONST + UNSPEC_TIE ]) ;; @@ -10828,7 +10829,9 @@ (define_expand "restore_stack_block" operands[4] = gen_frame_mem (Pmode, operands[1]); p = rtvec_alloc (1); RTVEC_ELT (p, 0) = gen_rtx_SET (gen_frame_mem (BLKmode, operands[0]), - const0_rtx); + gen_rtx_UNSPEC (BLKmode, + gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); operands[5] = gen_rtx_PARALLEL (VOIDmode, p); }) @@ -10866,7 +10869,9 @@ (define_expand "restore_stack_nonlocal" operands[5] = gen_frame_mem (Pmode, operands[3]); p = rtvec_alloc (1); RTVEC_ELT (p, 0) = gen_rtx_SET (gen_frame_mem (BLKmode, operands[0]), - const0_rtx); + gen_rtx_UNSPEC (BLKmode, + gen_rtvec (1, const0_rtx), + UNSPEC_TIE)); operands[6] = gen_rtx_PARALLEL (VOIDmode, p); }) @@ -13898,7 +13903,8 @@ (define_insn "*save_fpregs_<mode>_r1" ; not be moved over loads from or stores to stack memory. (define_insn "stack_tie" [(match_parallel 0 "tie_operand" - [(set (mem:BLK (reg 1)) (const_int 0))])] + [(set (mem:BLK (reg 1)) + (unspec:BLK [(const_int 0)] UNSPEC_TIE))])] "" "" [(set_attr "length" "0")]) @@ -13910,7 +13916,7 @@ (define_insn "stack_restore_tie" [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r") (match_operand:SI 2 "reg_or_cint_operand" "O,rI"))) - (set (mem:BLK (scratch)) (const_int 0))] + (set (mem:BLK (scratch)) (unspec:BLK [(const_int 0)] UNSPEC_TIE))] "TARGET_32BIT" "@ mr %0,%1 -- 2.39.3