]> git.ipfire.org Git - thirdparty/gcc.git/commit
[RISC-V] Improve (x << C1) + C2 split code
authorJeff Law <jlaw@ventanamicro.com>
Wed, 21 May 2025 22:04:58 +0000 (16:04 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Wed, 21 May 2025 22:04:58 +0000 (16:04 -0600)
commit0bed343a2a640c7be4a1970d303098ccf62bd1c6
tree5126db1c0b9ce78d29cf15735d7b1aa433d3822c
parent8459c546197dc9178d250994db021b36405f1bd6
[RISC-V] Improve (x << C1) + C2 split code

I wrote this a couple months ago to fix an instruction count regression in
505.mcf on risc-v, but I don't have a trivial little testcase to add to the
suite.

There were two problems with the pattern.

First, the code was generating a shift followed by an add after reload.
Naturally combine doesn't run after reload and the code stayed in that form
rather than using shadd when available.

Second the splitter was just over-active.  We need to make sure that the
shifted form of the constant operand has a cost > 1 to synthesize.  It's
useless to split if the shifted constant can be synthesized in a single
instruction.

This has been in my tester since March.  So it's been through numerous
riscv64-elf and riscv32-elf test cycles as well as multiple rv64 bootstrap
tests.  Waiting on the upstream CI system to render a verdict before moving
forward.

Looking further out I'm hoping this pattern will transform into a simpler and
always active define_split.

gcc/
* config/riscv/riscv.md ((x << C1) + C2): Tighten split condition
and generate more efficient code when splitting.
gcc/config/riscv/riscv.md