From: Richard Sandiford <richard.sandiford@arm.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: Jeff Law <jlaw@ventanamicro.com>,
gcc-patches@gcc.gnu.org, rdapp.gcc@gmail.com
Subject: Re: [PATCH] Add a late-combine pass [PR106594]
Date: Mon, 08 Jan 2024 19:11:55 +0000 [thread overview]
Message-ID: <mpt1qarzll0.fsf@arm.com> (raw)
In-Reply-To: <aaefa20e-c9dc-4afd-b12f-4d0f435b8f5b@gmail.com> (Jeff Law's message of "Mon, 8 Jan 2024 10:10:36 -0700")
Jeff Law <jeffreyalaw@gmail.com> writes:
> On 1/8/24 09:59, Richard Sandiford wrote:
>> This is a bit of a hopeful stab, but is the problem that recog_data still
>> had the previous contents of insn 3674, and so extract_insn_cached wrongly
>> thought that it doesn't need to do anything? If so, does something like:
>>
>> diff --git a/gcc/recog.cc b/gcc/recog.cc
>> index a6799e3f5e6..8ba63c78179 100644
>> --- a/gcc/recog.cc
>> +++ b/gcc/recog.cc
>> @@ -267,6 +267,8 @@ validate_change_1 (rtx object, rtx *loc, rtx new_rtx, bool in_group,
>> case invalid. */
>> changes[num_changes].old_code = INSN_CODE (object);
>> INSN_CODE (object) = -1;
>> + if (recog_data.insn == object)
>> + recog_data.insn = nullptr;
>> }
>>
>> num_changes++;
>>
>> fix it? I suppose there's an argument that this belongs in whatever code
>> sets INSN_CODE to a new nonnegative value (so recog_level2 for RTL-SSA).
>> But doing it in validate_change_1 seems more robust, since anything
>> calling that function is considering changing the insn code.
> Nope, doesn't help at all.
Yeah, in hindsight it was a dull guess. recog resets recog_data.insn
itself, so doing it here wasn't likely to help.
> I'd briefly put a reset of the INSN_CODE
> and a call to recog_memoized in the costing path of rtl-ssa to see if
> that would allow things to move forward, but it failed miserably.
>
> I'll pass along the .i file separately. Hopefully it'll fail for you
> and you can debug. But given failure depends on stale bits in
> recog_data, it may not.
Thanks. That led me to the following, which seems a bit more plausible
than my first attempt. I'll test it on aarch64-linux-gnu and
x86_64-linux-gnu. Does it look OK?
Richard
insn_info::calculate_cost computes the costs of unchanged insns lazily,
so that we don't waste time costing instructions that we never try to
change. It therefore has to revert any in-progress changes, cost the
original instruction, and then reapply the in-progress changes.
However, doing that temporarily changes the INSN_CODEs, and so
temporarily invalidates any information cached about the insn.
This means that insn_cost can end up looking at stale data,
or can cache data that becomes stale once the in-progress
changes are reapplied.
This could in principle happen for any use of temporarily_undo_changes
and redo_changes. Those functions in turn share a common subroutine,
swap_change, so that seems like the best place to fix this.
gcc/
* recog.cc (swap_change): Invalidate the cached recog_data if it
describes an insn that is being changed.
---
gcc/recog.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/recog.cc b/gcc/recog.cc
index a6799e3f5e6..56370e40e01 100644
--- a/gcc/recog.cc
+++ b/gcc/recog.cc
@@ -614,7 +614,11 @@ swap_change (int num)
else
std::swap (*changes[num].loc, changes[num].old);
if (changes[num].object && !MEM_P (changes[num].object))
- std::swap (INSN_CODE (changes[num].object), changes[num].old_code);
+ {
+ std::swap (INSN_CODE (changes[num].object), changes[num].old_code);
+ if (recog_data.insn == changes[num].object)
+ recog_data.insn = nullptr;
+ }
}
/* Temporarily undo all the changes numbered NUM and up, with a view
--
2.25.1
next prev parent reply other threads:[~2024-01-08 19:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 18:49 Richard Sandiford
2023-11-30 14:10 ` Ping: " Richard Sandiford
2023-12-11 15:23 ` Richard Sandiford
2023-12-11 16:18 ` Robin Dapp
2023-12-30 15:35 ` Ping^3: " Richard Sandiford
2024-01-01 3:11 ` YunQiang Su
2024-01-05 10:10 ` YunQiang Su
2023-12-30 18:13 ` Segher Boessenkool
2024-01-02 9:47 ` Richard Sandiford
2024-06-24 19:37 ` Segher Boessenkool
2024-06-25 10:31 ` Richard Biener
2024-06-25 17:22 ` YunQiang Su
2024-01-03 4:20 ` Jeff Law
2024-01-05 17:35 ` Richard Sandiford
2024-01-08 5:03 ` Jeff Law
2024-01-08 11:52 ` Richard Sandiford
2024-01-08 16:14 ` Jeff Law
2024-01-08 16:59 ` Richard Sandiford
2024-01-08 17:10 ` Jeff Law
2024-01-08 19:11 ` Richard Sandiford [this message]
2024-01-08 21:42 ` Jeff Law
2024-01-10 13:01 ` Richard Sandiford
2024-01-10 13:35 ` Richard Biener
2024-01-10 16:27 ` Jeff Law
2024-01-10 16:40 ` Jeff Law
2024-06-21 4:50 ` Hongtao Liu
2024-06-27 16:49 ` nvptx vs. " Thomas Schwinge
2024-06-27 20:27 ` Thomas Schwinge
2024-06-27 21:20 ` Thomas Schwinge
2024-06-27 22:41 ` Thomas Schwinge
2024-06-28 14:01 ` Richard Sandiford
2024-06-28 16:48 ` Richard Sandiford
2024-07-01 11:55 ` Thomas Schwinge
2024-07-01 11:55 ` WIP Move 'pass_fast_rtl_dce' from 'pass_postreload' into 'pass_late_compilation' (was: nvptx vs. [PATCH] Add a late-combine pass [PR106594]) Thomas Schwinge
2024-06-28 6:07 ` nvptx vs. [PATCH] Add a late-combine pass [PR106594] Roger Sayle
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=mpt1qarzll0.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=jlaw@ventanamicro.com \
--cc=rdapp.gcc@gmail.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).