public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiufu Guo <guojiufu@linux.ibm.com>
To: David Edelsohn <dje.gcc@gmail.com>
Cc: gcc-patches@gcc.gnu.org, segher@kernel.crashing.org,
	linkw@gcc.gnu.org, bergner@linux.ibm.com, rguenther@suse.de,
	richard.sandiford@arm.com
Subject: Re: [PATCH] rs6000: replace '(const_int 0)' to 'unspec:BLK [(const_int 0)]' for stack_tie
Date: Tue, 13 Jun 2023 10:15:49 +0800	[thread overview]
Message-ID: <7nv8fscdka.fsf@ltcden2-lp1.aus.stglabs.ibm.com> (raw)
In-Reply-To: <CAGWvnynpQzJX3tfxCgK4_YwKUoCJFamwg1BAfo3ML5BHDFhURw@mail.gmail.com> (David Edelsohn's message of "Mon, 12 Jun 2023 20:24:24 -0400")


Hi David,

David Edelsohn <dje.gcc@gmail.com> writes:

> Hi, Jiufu
>
> This definitely seems to be a better solution.
>
> The TARGET_CONST_ANCHOR change should not be part of this patch.  Also
> there is no ChangeLog for the patch.

Thanks a lot for your quick review!! And sorry for the sending this patch
in a hurry.  I would update the patch accordingly.


BR,
Jeff (Jiufu Guo)

>
> This generally looks correct and consistent with other ports. I want
> to give Segher a chance to double check it, if he wishes.
>
> Thanks David
>
> On Mon, Jun 12, 2023 at 9:19 AM Jiufu Guo <guojiufu@linux.ibm.com> wrote:
>>
>> 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 like other ports.
>>
>> This patch does this.  Bootstrap&regtest pass on ppc64{,le}.
>> Is this ok for trunk?
>>
>> BR,
>> Jeff (Jiufu Guo)
>>
>> ---
>>  gcc/config/rs6000/predicates.md   | 11 +++++++----
>>  gcc/config/rs6000/rs6000-logue.cc |  4 +++-
>>  gcc/config/rs6000/rs6000.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.cc b/gcc/config/rs6000/rs6000.cc
>> index d197c3f3289..0c81ebea711 100644
>> --- a/gcc/config/rs6000/rs6000.cc
>> +++ b/gcc/config/rs6000/rs6000.cc
>> @@ -1760,6 +1760,10 @@ static const struct attribute_spec rs6000_attribute_table[] =
>>
>>  #undef TARGET_UPDATE_IPA_FN_TARGET_INFO
>>  #define TARGET_UPDATE_IPA_FN_TARGET_INFO rs6000_update_ipa_fn_target_info
>> +
>> +#undef TARGET_CONST_ANCHOR
>> +#define TARGET_CONST_ANCHOR 0x8000
>> +
>>
>>
>>  /* Processor table.  */
>> 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
>>

  reply	other threads:[~2023-06-13  2:16 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 13:19 Jiufu Guo
2023-06-13  0:24 ` David Edelsohn
2023-06-13  2:15   ` Jiufu Guo [this message]
2023-06-13 18:14     ` Segher Boessenkool
2023-06-13 18:59       ` David Edelsohn
2023-06-14  3:00         ` Jiufu Guo
2023-06-13 12:23 Jiufu Guo
2023-06-13 12:48 ` Xi Ruoyao
2023-06-14  1:55   ` Jiufu Guo
2023-06-14  9:18     ` Xi Ruoyao
2023-06-14 15:05       ` Segher Boessenkool
2023-06-15  7:59         ` Jiufu Guo
2023-06-13 18:33 ` Segher Boessenkool
2023-06-14  4:06   ` Jiufu Guo
2023-06-14  7:59     ` Richard Biener
2023-06-14  9:04       ` Richard Sandiford
2023-06-14  9:22         ` Richard Biener
2023-06-14  9:43           ` Richard Sandiford
2023-06-14  9:52             ` Richard Biener
2023-06-14 10:02               ` Richard Sandiford
2023-06-14 16:08               ` Segher Boessenkool
2023-06-14 16:32           ` Segher Boessenkool
2023-06-14  9:29         ` Jiufu Guo
2023-06-14 16:38         ` Segher Boessenkool
2023-06-14  9:26       ` Jiufu Guo
2023-06-14 15:45         ` Segher Boessenkool
2023-06-14 15:38       ` Segher Boessenkool
2023-06-14 16:25         ` Richard Biener
2023-06-14 17:03           ` Segher Boessenkool
2023-06-14 15:15     ` Segher Boessenkool
2023-06-15  7:00       ` Jiufu Guo
2023-06-15 16:30         ` Segher Boessenkool
2023-06-16  2:24           ` Jiufu Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7nv8fscdka.fsf@ltcden2-lp1.aus.stglabs.ibm.com \
    --to=guojiufu@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linkw@gcc.gnu.org \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).