public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "guihaoc at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/93453] PPC: rldimi not taken into account to avoid shift+or Date: Thu, 25 Nov 2021 03:31:59 +0000 [thread overview] Message-ID: <bug-93453-4-DCAB17Z9J3@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-93453-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93453 --- Comment #8 from HaoChen Gui <guihaoc at gcc dot gnu.org> --- I refined the patch and put all things in a helper - change_pseudo_and_mask. As you mentioned, it's still a band-aid. The perfect solution might be a better version of nonzero_bits. Thanks. diff --git a/gcc/combine.c b/gcc/combine.c index 892c834a160..f0e6ca5d8cf 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11539,6 +11539,41 @@ change_zero_ext (rtx pat) return changed; } +/* Convert a psuedo to psuedo AND with a mask if its nonzero_bits is less + than its mode mask. */ +static bool +change_pseudo_and_mask (rtx pat) +{ + bool changed = false; + + rtx src = SET_SRC (pat); + if ((GET_CODE (src) == IOR + || GET_CODE (src) == XOR + || GET_CODE (src) == PLUS) + && (((GET_CODE (XEXP (src, 0)) == ASHIFT + || GET_CODE (XEXP (src, 0)) == LSHIFTRT + || GET_CODE (XEXP (src, 0)) == AND) + && REG_P (XEXP (src, 1))) + || ((GET_CODE (XEXP (src, 1)) == ASHIFT + || GET_CODE (XEXP (src, 1)) == LSHIFTRT + || GET_CODE (XEXP (src, 1)) == AND) + && REG_P (XEXP (src, 0))))) + { + rtx *reg = REG_P (XEXP (src, 0)) + ? &XEXP (SET_SRC (pat), 0) + : &XEXP (SET_SRC (pat), 1); + machine_mode mode = GET_MODE (*reg); + unsigned HOST_WIDE_INT nonzero = nonzero_bits (*reg, mode); + if (nonzero < GET_MODE_MASK (mode)) + { + rtx x = gen_rtx_AND (mode, *reg, GEN_INT (nonzero)); + SUBST (*reg, x); + changed = true; + } + } + return changed; +} + /* Like recog, but we receive the address of a pointer to a new pattern. We try to match the rtx that the pointer points to. If that fails, we may try to modify or replace the pattern, @@ -11565,9 +11600,18 @@ recog_for_combine (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) void *marker = get_undo_marker (); bool changed = false; + //bool PIX_opt = false; if (GET_CODE (pat) == SET) - changed = change_zero_ext (pat); + { + changed = change_pseudo_and_mask (pat); + if (changed) + { + maybe_swap_commutative_operands (SET_SRC (pat)); + //PIX_opt = true; + } + changed |= change_zero_ext (pat); + } else if (GET_CODE (pat) == PARALLEL) { int i; @@ -11585,6 +11629,8 @@ recog_for_combine (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) if (insn_code_number < 0) undo_to_marker (marker); + //else if (PIX_opt) + //fprintf (stdout, "PIX applied\n"); } return insn_code_number;
next prev parent reply other threads:[~2021-11-25 3:31 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-93453-4@http.gcc.gnu.org/bugzilla/> 2021-11-09 2:38 ` guihaoc at gcc dot gnu.org 2021-11-09 11:56 ` segher at gcc dot gnu.org 2021-11-16 2:58 ` guihaoc at gcc dot gnu.org 2021-11-22 19:51 ` segher at gcc dot gnu.org 2021-11-23 2:46 ` guihaoc at gcc dot gnu.org 2021-11-23 19:44 ` segher at gcc dot gnu.org 2021-11-25 3:31 ` guihaoc at gcc dot gnu.org [this message] 2021-11-25 17:40 ` segher at gcc dot gnu.org
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=bug-93453-4-DCAB17Z9J3@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.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: linkBe 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).