]> git.ipfire.org Git - thirdparty/gcc.git/commit
[V2][RISC-V] Avoid unnecessary extensions after sCC insns
authorJeff Law <jlaw@ventanamicro.com>
Thu, 5 Sep 2024 21:45:25 +0000 (15:45 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Thu, 5 Sep 2024 21:45:25 +0000 (15:45 -0600)
commitb567e5ead5d54f022c57b48f31653f6ae6ece007
treee3f8f7e9e241767d3f5e844c1014319f51f3de1b
parentb214ffeecb3f480dd7864bcbfc9ac30100c126f3
[V2][RISC-V] Avoid unnecessary extensions after sCC insns

So the first patch failed the pre-commit CI; it didn't fail in my testing
because I'm using --with-arch to set a default configuration that includes
things like zicond to ensure that's always tested.  And the failing test is
skipped when zicond is enabled by default.

The failing test is designed to ensure that we don't miss an if-conversion due
to costing issues around the extension that was typically done in an sCC
sequence (which is why it's only run when zicond is off).

The test failed because we have a little routine that is highly dependent on
the code generated by the sCC expander and will adjust the costing to account
for expansion quirks that usually go away in register allocation.

That code needs to be enhanced to work after the sCC expansion change.
Essentially it needs to account for the subreg extraction that shows up in the
sequence as well as being a bit looser on mode checking.

I kept the code working for the old sequences -- in theory a user could conjure
up the old sequence so handling them seems useful.

This also drops the testsuite changes.  Palmer's change makes them unnecessary.

---

So I was looking at a performance regression in spec with Ventana's internal
tree.  Ultimately the problem was a bad interaction with an internal patch
(REP_MODE_EXTENDED), fwprop and ext-dce.  The details of that problem aren't
particularly important.

Removal of the local patch went reasonably well.  But I did see some secondary
cases where we had redundant sign extensions.  The most notable cases come from
the integer sCC insns.

Expansion of those cases for rv64 can be improved using Jivan's trick. ie, if
the target is not DImode, then create a DImode temporary for the result and
copy the low bits out with a promoted subreg to the real target.

With the change in expansion the final code we generate is slightly different
for a few tests at -O1/-Og, but should perform the same.  The key for the
affected tests is we're not seeing the introduction of unnecessary extensions.
Rather than adjust the regexps to handle the -O1/-Og output, skipping for those
seemed OK to me.  I didn't extract a testcase.  I'm a bit fried from digging
through LTO'd code right now.

gcc/
* config/riscv/riscv.cc (riscv_expand_int_scc): For rv64, use a DI
temporary for the output and a promoted subreg to extract it into SI
arget.
(riscv_noce_conversion_profitable_p): Recognize new output from
sCC expansion too.
gcc/config/riscv/riscv.cc