From: "Fei Gao" <gaofei@eswincomputing.com>
To: jeffreyalaw <jeffreyalaw@gmail.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "Kito Cheng" <kito.cheng@gmail.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
zengxiao <zengxiao@eswincomputing.com>
Subject: Re: Re: [PATCH 5/5] [ifcvt] optimize extension for x=c ? (y op z) : y by RISC-V Zicond like insns
Date: Thu, 14 Dec 2023 17:32:16 +0800 [thread overview]
Message-ID: <2023121417321633750537@eswincomputing.com> (raw)
In-Reply-To: <b1db4e7d-ef5a-4c51-b171-b9521d0233a3@gmail.com>
On 2023-12-11 13:46 Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
>On 12/5/23 01:12, Fei Gao wrote:
>> SIGN_EXTEND, ZERO_EXTEND and SUBREG has been considered
>> to support SImode in 64-bit machine.
>>
>> Co-authored-by: Xiao Zeng<zengxiao@eswincomputing.com>
>>
>> gcc/ChangeLog:
>>
>> * ifcvt.cc (noce_cond_zero_binary_op_supported): add support for extension
>> (noce_bbs_ok_for_cond_zero_arith): likewise
>> (noce_try_cond_zero_arith): support extension of LSHIFTRT case
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.target/riscv/zicond_ifcvt_opt.c: add TCs for extension
>So I think this needs to defer to gcc-15. But even so I think getting
>some review on the effort is useful.
>
>
>> ---
>> gcc/ifcvt.cc | 16 ++-
>> .../gcc.target/riscv/zicond_ifcvt_opt.c | 126 +++++++++++++++++-
>> 2 files changed, 139 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
>> index b84be53ec5c..306497a8e37 100644
>> --- a/gcc/ifcvt.cc
>> +++ b/gcc/ifcvt.cc
>> @@ -2934,6 +2934,10 @@ noce_cond_zero_binary_op_supported (rtx op)
>> {
>> enum rtx_code opcode = GET_CODE (op);
>>
>> + /* Strip SIGN_EXTEND or ZERO_EXTEND if any. */
>> + if (opcode == SIGN_EXTEND || opcode == ZERO_EXTEND)
>> + opcode = GET_CODE (XEXP (op, 0));
>So it seems to me like that you need to record what the extension was so
>that you can re-apply it to the result.
>
>> @@ -3114,7 +3122,11 @@ noce_try_cond_zero_arith (struct noce_if_info *if_info)
>> if (CONST_INT_P (*to_replace))
>> {
>> if (noce_cond_zero_shift_op_supported (bin_code))
>> - *to_replace = gen_rtx_SUBREG (E_QImode, target, 0);
>> + {
>> + *to_replace = gen_rtx_SUBREG (E_QImode, target, 0);
>> + if (GET_CODE (a) == ZERO_EXTEND && bin_code == LSHIFTRT)
>> + PUT_CODE (a, SIGN_EXTEND);
>> + }
>This doesn't look correct (ignoring the SUBREG issues with patch #4 in
>this series).
Agree there's issue here for const_int case as you mentioned in
[PATCH 4/5] [ifcvt] optimize x=c ? (y op const_int) : y.
>
>When we looked at this internally the conclusion was we needed to first
>strip the extension, recording what kind of extension it was, then
>reapply the same extension to the result of the now conditional
>operation. And it's independent of SUBREG handling.
Ignoring the const_int case, we can reuse the RTL pattern and replace
the z(SUBREG pr REG) in INSN_A(x=y op z) without recording what kind
of extension it was.
New patch will be sent to gcc15.
BR,
Fei
>
>
>Jeff
next prev parent reply other threads:[~2023-12-14 9:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 8:12 [PATCH 1/5][V3][ifcvt] optimize " Fei Gao
2023-12-05 8:12 ` [PATCH 2/5] [ifcvt] optimize x=c ? (y shift_op z):y " Fei Gao
2023-12-10 20:43 ` Jeff Law
2023-12-11 4:01 ` Fei Gao
2023-12-11 6:15 ` Jeff Law
2023-12-05 8:12 ` [PATCH 3/5] [ifcvt] optimize x=c ? (y AND z) : y " Fei Gao
2023-12-11 5:16 ` Jeff Law
2023-12-05 8:12 ` [PATCH 4/5] [ifcvt] optimize x=c ? (y op const_int) " Fei Gao
2023-12-11 5:38 ` Jeff Law
2023-12-14 8:42 ` Fei Gao
2023-12-05 8:12 ` [PATCH 5/5] [ifcvt] optimize extension for x=c ? (y op z) " Fei Gao
2023-12-11 5:46 ` Jeff Law
2023-12-14 9:32 ` Fei Gao [this message]
2023-12-08 0:49 ` [PATCH 1/5][V3][ifcvt] optimize " Jeff Law
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=2023121417321633750537@eswincomputing.com \
--to=gaofei@eswincomputing.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=palmer@dabbelt.com \
--cc=zengxiao@eswincomputing.com \
/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).