RISC-V: avoid splitting small constant in <or_optab>i<mode>_extrabit pattern
authorLin Sinan <mynameisxiaou@gmail.com>
Tue, 11 Apr 2023 16:23:19 +0000 (10:23 -0600)
committerJeff Law <jlaw@ventanamicro>
Tue, 11 Apr 2023 16:26:59 +0000 (10:26 -0600)
commit0c5e64c4249322a178e1a0e843874e4d6b43b992
tree901d215d9f283ce9c1d30d191d2e0b094d15de6e
parent40fc8e3d4f600d89e6b065d6f12db7a816269c8f
RISC-V: avoid splitting small constant in <or_optab>i<mode>_extrabit pattern

there is no need to split an xori/ori with an small constant. take the test
case `int foo(int idx) { return idx|3; }` as an example,

rv64im_zba generates:
        ori     a0,a0,3
        ret
but, rv64im_zba_zbs generates:
        ori     a0,a0,1
        ori     a0,a0,2
        ret

with this change, insn `ori r2,r1,3` will not be splitted in zbs.

gcc/
* config/riscv/predicates.md (uimm_extra_bit_or_twobits): Adjust
predicate to avoid splitting arith constants.

gcc/testsuite

* gcc.target/riscv/zbs-extra-bit-or-twobits.c: New test.
gcc/config/riscv/predicates.md
gcc/testsuite/gcc.target/riscv/zbs-extra-bit-or-twobits.c [new file with mode: 0644]