From: Ajit Agarwal <aagarwa1@linux.ibm.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
bergner@linux.ibm.com, Jeff Law <jeffreyalaw@gmail.com>,
Richard Biener <richard.guenther@gmail.com>
Subject: [PATCH] rtl-optimization: ppc backend generates unnecessary signed extension.
Date: Thu, 23 Mar 2023 16:08:32 +0530 [thread overview]
Message-ID: <4c0b6b4f-bbc1-8dd0-a91c-ffed028b4873@linux.ibm.com> (raw)
Hello All:
This patch removed unnecessary signed extension elimination in ree pass.
Bootstrapped and regtested on powerpc64-linux-gnu.
Thanks & Regards
Ajit
rtl-optimization: ppc backend generates unnecessary signed extension.
Eliminate unnecessary redundant signed extension.
2023-03-23 Ajit Kumar Agarwal <aagarwa1@linux.ibm.com>
gcc/ChangeLog:
* ree.cc: Modification for AND opcode support to eliminate
unnecessary signed extension.
* testsuite/g++.target/powerpc/sext-elim.C: New tests.
---
gcc/ree.cc | 24 +++++++++++++++++---
gcc/testsuite/g++.target/powerpc/sext-elim.C | 19 ++++++++++++++++
2 files changed, 40 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.target/powerpc/sext-elim.C
diff --git a/gcc/ree.cc b/gcc/ree.cc
index d09f55149b1..63d8cf9f237 100644
--- a/gcc/ree.cc
+++ b/gcc/ree.cc
@@ -364,6 +364,7 @@ combine_set_extension (ext_cand *cand, rtx_insn *curr_insn, rtx *orig_set)
rtx simplified_temp_extension = simplify_rtx (temp_extension);
if (simplified_temp_extension)
temp_extension = simplified_temp_extension;
+
new_set = gen_rtx_SET (new_reg, temp_extension);
}
else if (GET_CODE (orig_src) == IF_THEN_ELSE)
@@ -375,11 +376,21 @@ combine_set_extension (ext_cand *cand, rtx_insn *curr_insn, rtx *orig_set)
else
{
/* This is the normal case. */
- rtx temp_extension
- = gen_rtx_fmt_e (cand->code, cand->mode, orig_src);
+ rtx temp_extension = NULL_RTX;
+
+ if (GET_CODE (SET_SRC (cand_pat)) == AND)
+ temp_extension
+ = gen_rtx_fmt_ee (cand->code, cand->mode,orig_src,
+ XEXP (SET_SRC (cand_pat), 1));
+ else
+ temp_extension
+ = gen_rtx_fmt_e (cand->code, cand->mode,orig_src);
+
rtx simplified_temp_extension = simplify_rtx (temp_extension);
+
if (simplified_temp_extension)
temp_extension = simplified_temp_extension;
+
new_set = gen_rtx_SET (new_reg, temp_extension);
}
@@ -1047,7 +1058,14 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
cannot be merged, we entirely give up. In the future, we should allow
extensions to be partially eliminated along those paths where the
definitions could be merged. */
- if (apply_change_group ())
+ int num_clobbers = 0;
+ int icode = recog (cand->insn, cand->insn,
+ (GET_CODE (cand->expr) == SET
+ && ! reload_completed
+ && ! reload_in_progress)
+ ? &num_clobbers : 0);
+
+ if (apply_change_group () || (icode < 0))
{
if (dump_file)
fprintf (dump_file, "All merges were successful.\n");
diff --git a/gcc/testsuite/g++.target/powerpc/sext-elim.C b/gcc/testsuite/g++.target/powerpc/sext-elim.C
new file mode 100644
index 00000000000..1180b9ce268
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/sext-elim.C
@@ -0,0 +1,19 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-options "-mcpu=power9 -O2 -free" } */
+
+unsigned long c2l(unsigned char* p)
+{
+ unsigned long res = *p + *(p+1);
+ return res;
+}
+
+long c2sl(signed char* p)
+{
+ long res = *p + *(p+1);
+ return res;
+}
+
+/* { dg-final { scan-assembler-not "rldicl" } } */
+/* { dg-final { scan-assembler-not "extsw" } } */
--
2.31.1
next reply other threads:[~2023-03-23 10:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 10:38 Ajit Agarwal [this message]
2023-03-23 12:38 ` Peter Bergner
2023-03-23 15:32 ` Ajit Agarwal
2023-03-23 15:32 ` Ajit Agarwal
2023-03-23 16:29 ` Peter Bergner
2023-03-23 16:32 ` Jeff Law
2023-03-23 16:53 ` Peter Bergner
2023-03-23 23:12 ` Jeff Law
2023-03-24 21:34 ` Peter Bergner
2023-03-25 18:09 ` Jeff Law
2023-03-31 0:01 ` Hans-Peter Nilsson
2023-03-31 14:01 ` Jeff Law
2023-03-23 13:47 ` Jeff Law
2023-03-23 15:36 ` Ajit Agarwal
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=4c0b6b4f-bbc1-8dd0-a91c-ffed028b4873@linux.ibm.com \
--to=aagarwa1@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--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).