public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Vineet Gupta <vineetg@rivosinc.com>,
	gcc@gcc.gnu.org, Kito Cheng <kito.cheng@sifive.com>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>
Subject: Re: Redundant constants in coremark crc8 for RISCV/aarch64 (no-if-conversion)
Date: Wed, 19 Oct 2022 07:30:44 -0600	[thread overview]
Message-ID: <feb53854-4b6d-0a60-36e9-413f5defe567@gmail.com> (raw)
In-Reply-To: <CAFiYyc2F=rBh4k_qTeSxa2cNTCWzrS+hEi+UzSY2eKkTkHq5PA@mail.gmail.com>


On 10/19/22 01:46, Richard Biener wrote:
> On Wed, Oct 19, 2022 at 5:44 AM Jeff Law via Gcc <gcc@gcc.gnu.org> wrote:
>>
>> On 10/18/22 20:09, Vineet Gupta wrote:
>>> On 10/18/22 16:36, Jeff Law wrote:
>>>>>> There isn't a great place in GCC to handle this right now.  If the
>>>>>> constraints were relaxed in PRE, then we'd have a chance, but
>>>>>> getting the cost model right is going to be tough.
>>>>> It would have been better (for this specific case) if loop unrolling
>>>>> was not being done so early. The tree pass cunroll is flattening it
>>>>> out and leaving for rest of the all tree/rtl passes to pick up the
>>>>> pieces and remove any redundancies, if at all. It obviously needs to
>>>>> be early if we are injecting 7x more instructions, but seems like a
>>>>> lot to unravel.
>>>> Yup.  If that loop gets unrolled, it's going to be a mess.  It will
>>>> almost certainly make this problem worse as each iteration is going
>>>> to have a pair of constants loaded and no good way to remove them.
>>> Thats the original problem that I started this thread with. I'd
>>> snipped the disassembly as it would have been too much text but
>>> basically on RV, Coremark crc8 loop of const 8 iterations gets
>>> unrolled including extraneous 8 insns pairs to load the same constant
>>> - which is preposterous. Other arches side-step by using if-conversion
>>> / cond moves, latter currently WIP in RV International. x86 w/o
>>> if-convert seems OK since the const can be encoded in the xor insn.
>>>
>>> OTOH given that gimple/tree-pass cunroll is doing the culprit loop
>>> unrolling and introducing redundant const 8 times, can it ne addressed
>>> there somehow.
>>> tree_estimate_loop_size() seems to identify constant expression, not
>>> just an operand. Can it be taught to identify a "non-trivial const"
>>> and hoist/code-move the expression. Sorry just rambling here, most
>>> likely non-sense.
> On GIMPLE all constants are "simple".
>
>> Oh, cunroll.  There might be a distinct flag for complete unrolling.
> At -O3 we peel completely, there's no flag to disable that.
>
>> I really expect something like Click's work is the way forward.
>> Essentially when you VN the function you'll identify those constants and
>> collapse them all down to a single instance.  Then the GCM phase will
>> kick in and find a place to put the evaluation so that you have one and
>> only one.
> I'd say postreload gcse would be a place to do that.  At least when
> there's no available hardreg CSEing likely isn't going to be a win.

That's an interesting idea.  Do it aggressively post-reload when we know 
there's a register available.   Vineet, that seems like it's worth 
investigation.

jeff



      reply	other threads:[~2022-10-19 13:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 15:56 Vineet Gupta
2022-10-14 16:54 ` Jeff Law
2022-10-18 21:51   ` Vineet Gupta
2022-10-18 23:36     ` Jeff Law
2022-10-19  2:09       ` Vineet Gupta
2022-10-19  3:42         ` Jeff Law
2022-10-19  7:46           ` Richard Biener
2022-10-19 13:30             ` Jeff Law [this message]

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=feb53854-4b6d-0a60-36e9-413f5defe567@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kito.cheng@sifive.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=richard.guenther@gmail.com \
    --cc=vineetg@rivosinc.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).