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: Tue, 23 Nov 2021 02:46:17 +0000 [thread overview] Message-ID: <bug-93453-4-hjdKWRCToo@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 #6 from HaoChen Gui <guihaoc at gcc dot gnu.org> --- Sehger, Yes, I found that the nonzero_bits doesn't return exact value in other pass. So calling nonzero_bits in md file is bad as it can't be recognized in other pass. Right now I want to convert a single pseudo to the pseudo AND with a mask in combine pass if its nonzero_bits is less than its mode mask and the outer operation is plus/ior/xor and its one of inner operation is ashift/lshiftrt/and. Thus it is possible to match rotate and insert pattern. What's your opinion? Thanks a lot. (ior:DI (ashift:DI (reg:DI 125) (const_int 32 [0x20])) (reg:DI 126))) is converted to (ior:DI (ashift:DI (reg:DI 125) (const_int 32 [0x20])) (and:DI (reg:DI 126) (const_int 4294967295 [0xfffffff])))) patch.diff diff --git a/gcc/combine.c b/gcc/combine.c index 892c834a160..8b72a5ec831 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11539,6 +11539,26 @@ 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 +pseudo_and_with_mask (rtx *reg) +{ + bool changed = false; + gcc_assert (REG_P (*reg)); + + 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; + //fprintf (stdout, "PIX optimization\n"); + } + 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 +11585,34 @@ 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); + { + 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))))) + { + changed = REG_P (XEXP (src, 0)) + ? pseudo_and_with_mask (&XEXP (SET_SRC (pat), 0)) + : pseudo_and_with_mask (&XEXP (SET_SRC (pat), 1)); + 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 +11630,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-23 2:46 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 [this message] 2021-11-23 19:44 ` segher at gcc dot gnu.org 2021-11-25 3:31 ` guihaoc at gcc dot gnu.org 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-hjdKWRCToo@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).