From: Ajit Agarwal <aagarwa1@linux.ibm.com>
To: Jeff Law <jeffreyalaw@gmail.com>, Hans-Peter Nilsson <hp@bitrange.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
Segher Boessenkool <segher@kernel.crashing.org>,
Peter Bergner <bergner@linux.ibm.com>,
Richard Biener <richard.guenther@gmail.com>
Subject: Re: [PATCH v4 4/4] ree: Improve ree pass for rs6000 target using defined ABI interfaces.
Date: Tue, 16 May 2023 18:05:30 +0530 [thread overview]
Message-ID: <438860a6-4c03-2d5b-c465-833998e80bab@linux.ibm.com> (raw)
In-Reply-To: <77213cc0-f666-8233-5af7-0aa199455b54@gmail.com>
On 29/04/23 5:03 am, Jeff Law wrote:
>
>
> On 4/28/23 16:42, Hans-Peter Nilsson wrote:
>> On Sat, 22 Apr 2023, Ajit Agarwal via Gcc-patches wrote:
>>
>>> Hello All:
>>>
>>> This new version of patch 4 use improve ree pass for rs6000 target using defined ABI interfaces.
>>> Bootstrapped and regtested on power64-linux-gnu.
>>>
>>> Thanks & Regards
>>> Ajit
>>>
>>>
>>> ree: Improve ree pass for rs6000 target using defined abi interfaces
>>>
>>> For rs6000 target we see redundant zero and sign
>>> extension and done to improve ree pass to eliminate
>>> such redundant zero and sign extension using defines
>>> ABI interfaces.
>>>
>>> 2023-04-22 Ajit Kumar Agarwal <aagarwa1@linux.ibm.com>
>>>
>>> gcc/ChangeLog:
>>>
>>> * ree.cc (combline_reaching_defs): Add zero_extend
>>> using defined abi interfaces.
>>> (add_removable_extension): use of defined abi interfaces
>>> for no reaching defs.
>>> (abi_extension_candidate_return_reg_p): New defined ABI function.
>>> (abi_extension_candidate_p): New defined ABI function.
>>> (abi_extension_candidate_argno_p): New defined ABI function.
>>> (abi_handle_regs_without_defs_p): New defined ABI function.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> * g++.target/powerpc/zext-elim-3.C
>>> ---
>>> gcc/ree.cc | 176 +++++++++++++++---
>>> .../g++.target/powerpc/zext-elim-3.C | 16 ++
>>> 2 files changed, 162 insertions(+), 30 deletions(-)
>>> create mode 100644 gcc/testsuite/g++.target/powerpc/zext-elim-3.C
>>>
>>> diff --git a/gcc/ree.cc b/gcc/ree.cc
>>> index 413aec7c8eb..0de96b1ece1 100644
>>> --- a/gcc/ree.cc
>>> +++ b/gcc/ree.cc
>>> @@ -473,7 +473,8 @@ get_defs (rtx_insn *insn, rtx reg, vec<rtx_insn *> *dest)
>>> break;
>>> }
>>> - gcc_assert (use != NULL);
>>> + if (use == NULL)
>>> + return NULL;
>>> ref_chain = DF_REF_CHAIN (use);
>>> @@ -514,7 +515,8 @@ get_uses (rtx_insn *insn, rtx reg)
>>> if (REGNO (DF_REF_REG (def)) == REGNO (reg))
>>> break;
>>> - gcc_assert (def != NULL);
>>> + if (def == NULL)
>>> + return NULL;
>>> ref_chain = DF_REF_CHAIN (def);
>>> @@ -750,6 +752,103 @@ get_extended_src_reg (rtx src)
>>> return src;
>>> }
>>> +/* Return TRUE if the candidate insn is zero extend and regno is
>>> + an return registers. */
>>> +
>>> +static bool
>>> +abi_extension_candidate_return_reg_p (rtx_insn *insn, int regno)
>>> +{
>>> + rtx set = single_set (insn);
>>> +
>>> + if (GET_CODE (SET_SRC (set)) != ZERO_EXTEND)
>>> + return false;
>>> +
>>> + if (FUNCTION_VALUE_REGNO_P (regno))
>>> + return true;
>>> +
>>> + return false;
>>> +}
>>> +
>>> +/* Return TRUE if reg source operand of zero_extend is argument registers
>>> + and not return registers and source and destination operand are same
>>> + and mode of source and destination operand are not same. */
>>> +
>>> +static bool
>>> +abi_extension_candidate_p (rtx_insn *insn)
>>> +{
>>> + rtx set = single_set (insn);
>>> +
>>> + if (GET_CODE (SET_SRC (set)) != ZERO_EXTEND)
>>> + return false;
>>> +
>>> + machine_mode ext_dst_mode = GET_MODE (SET_DEST (set));
>>> + rtx orig_src = XEXP (SET_SRC (set),0);
>>> +
>>> + bool copy_needed
>>> + = (REGNO (SET_DEST (set)) != REGNO (XEXP (SET_SRC (set), 0)));
>>> +
>>> + if (!copy_needed && ext_dst_mode != GET_MODE (orig_src)
>>> + && FUNCTION_ARG_REGNO_P (REGNO (orig_src))
>>> + && !abi_extension_candidate_return_reg_p (insn, REGNO (orig_src)))
>>> + return true;
>>> +
>>> + return false;
>>> +}
>>> +
>>> +/* Return TRUE if the candidate insn is zero extend and regno is
>>> + an argument registers. */
>>> +
>>> +static bool
>>> +abi_extension_candidate_argno_p (rtx_code code, int regno)
>>> +{
>>> + if (code != ZERO_EXTEND)
>>> + return false;
>>> +
>>> + if (FUNCTION_ARG_REGNO_P (regno))
>>> + return true;
>>> +
>>> + return false;
>>> +}
>>
>> I don't see anything in those functions that checks if
>> ZERO_EXTEND is actually a feature of the ABI, e.g. as opposed to
>> no extension or SIGN_EXTEND. Do I miss something?
> I don't think you missed anything. That was one of the points I was making last week. Somewhere, somehow we need to describe what the ABI mandates and guarantees.
>
> So while what Ajit has done is a step forward, at some point the actual details of the ABI need to be described in a way that can be checked and consumed by REE.
The ABI we need for ree pass are the argument registers and return registers. Based on that I have described interfaces that we need. Other than that we dont any other ABI hooks. I have used FUNCTION_VALUE_REGNO_P and FuNCTION_ARG_REGNO_P abi hooks.
Thanks & Regards
Ajit
>
> Jeff
next prev parent reply other threads:[~2023-05-16 12:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 9:06 Ajit Agarwal
2023-04-28 22:42 ` Hans-Peter Nilsson
2023-04-28 23:33 ` Jeff Law
2023-04-28 23:49 ` Hans-Peter Nilsson
2023-05-02 22:00 ` Peter Bergner
2023-05-16 12:35 ` Ajit Agarwal [this message]
2023-05-19 19:32 ` Jeff Law
2023-05-01 16:21 ` Segher Boessenkool
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=438860a6-4c03-2d5b-c465-833998e80bab@linux.ibm.com \
--to=aagarwa1@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hp@bitrange.com \
--cc=jeffreyalaw@gmail.com \
--cc=richard.guenther@gmail.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).