public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Roger Sayle <sayle@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3251] Only simplify TRUNCATE to SUBREG on TRULY_NOOP_TRUNCATION targets. Date: Tue, 31 Aug 2021 10:43:10 +0000 (GMT) [thread overview] Message-ID: <20210831104310.5A83D3858409@sourceware.org> (raw) https://gcc.gnu.org/g:0960d937d9bee3c831d0b64a9c828c263a58ff89 commit r12-3251-g0960d937d9bee3c831d0b64a9c828c263a58ff89 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Tue Aug 31 11:41:57 2021 +0100 Only simplify TRUNCATE to SUBREG on TRULY_NOOP_TRUNCATION targets. As recently remarked by Jeff Law, SUBREGs are the "forever chemicals" of GCC's RTL; once created they persist in the environment. The problem, according to the comment on lines 5428-5438 of combine.c is that non-tieable SUBREGs interfere with reload/register allocation, so combine often doesn't touch/clean-up instructions containing a SUBREG. This is the first and simplest of two patches to tackle that problem, by teaching combine to avoid converting explicit TRUNCATEs into SUBREGs that it can't handle. Consider the following (hypothetical) sequence of instructions on a STORE_FLAG_VALUE=1 target, which stores a zero or one in an SI register, then uselessly truncates to QImode, then extends it again. (set (reg:SI 27) (ne:SI (reg:BI 28) (const_int 0))) (set (reg:QI 26) (truncate:QI (reg:SI 27))) (set (reg:SI 0) (zero_extend:SI (reg:QI 26))) which ideally (i.e. with this patch) combine would simplify to: (set (reg:SI 0) (ne:SI (reg:BI 28) (const_int 0))) Alas currently, during combine the middle TRUNCATE is converted into a lowpart SUBREG, which subst then turns into (clobber (const_int 0)), abandoning the attempted combination, that then never reaches recog. 2021-08-31 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * combine.c (combine_simplify_rtx): Avoid converting an explicit TRUNCATE into a lowpart SUBREG on !TRULY_NOOP_TRUNCATION targets. * simplify-rtx.c (simplify_unary_operation_1): Likewise. Diff: --- gcc/combine.c | 3 ++- gcc/simplify-rtx.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index cb5fa401fcb..290a3667c65 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5903,7 +5903,8 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, if (HWI_COMPUTABLE_MODE_P (mode) && (STORE_FLAG_VALUE & ~GET_MODE_MASK (mode)) == 0 && (temp = get_last_value (XEXP (x, 0))) - && COMPARISON_P (temp)) + && COMPARISON_P (temp) + && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (XEXP (x, 0)))) return gen_lowpart (mode, XEXP (x, 0)); break; diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index c81e27eb008..e431e0c19d7 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1249,7 +1249,8 @@ simplify_context::simplify_unary_operation_1 (rtx_code code, machine_mode mode, than HOST_BITS_PER_WIDE_INT. */ if (HWI_COMPUTABLE_MODE_P (mode) && COMPARISON_P (op) - && (STORE_FLAG_VALUE & ~GET_MODE_MASK (mode)) == 0) + && (STORE_FLAG_VALUE & ~GET_MODE_MASK (mode)) == 0 + && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (op))) { temp = rtl_hooks.gen_lowpart_no_emit (mode, op); if (temp)
reply other threads:[~2021-08-31 10:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210831104310.5A83D3858409@sourceware.org \ --to=sayle@gcc.gnu.org \ --cc=gcc-cvs@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).