gnu/gcc/e07e140680c717cfc59a11bf2287ff6433ebddd2 [RISC-V] Improve IOR/XOR synthesis for expensive constant cases
So much like the changes to add_synthesis, this adjusts xor/ior synthesis to
use riscv_integer_cost rather than riscv_const_insns. For those that didn't
read the add_synthesis patch, what happens is riscv_const_insns returns 0 for
constants requiring more than 3 insns to synthesize. So imagine if the
original constant had cost 5, it's bit inversion has cost 4. Both get
converted to "0" because they're over the maximal value and thus we can't
distinguish between them and we fail to use C' with XNOR, ORN or ANDN to
improve the resulting code.
The constants here were actually from the AND cases, but given the common ISA
capability and GCC structure I suspected the AND cases would apply to IOR/XOR,
and they do.
Tested without regression on riscv32-elf and riscv64-elf, also bootstrapped and
regression tested on the k3 and c920. I'll obviously be waiting for pre-commit
CI to do its thing before moving forward.
gcc/
* config/riscv/riscv.cc (synthesize_ior_xor): Use riscv_integer_cost
rather than riscv_const_insns.
gcc/testsuite
* gcc.target/riscv/xor-synthesis-4.c: New test.
2 files changed