[RISC-V] [PATCH v2] Enable inlining str* by default
commit1139f38e798181572121657e5b267a9698edb62f
authorJeff Law <jlaw@ventanamicro.com>
Tue, 7 May 2024 17:43:09 +0000 (7 11:43 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Tue, 7 May 2024 17:43:09 +0000 (7 11:43 -0600)
tree64c02b5b02ffb797dc09fde69f18cdfd3307c8a9
parentd6d7afcdbc04adb0ec42a44b2d7e05600945af42
[RISC-V] [PATCH v2] Enable inlining str* by default

So with Chrstoph's patches from late 2022 we've had the ability to inline
strlen, and str[n]cmp (scalar).  However, we never actually turned this
capability on by default!

This patch flips the those default to allow inlinining by default.  It also
fixes one bug exposed by our internal testing when NBYTES is zero for strncmp.
I don't think that case happens enough to try and optimize it, we just disable
inline expansion for that instance.

This has been bootstrapped and regression tested on rv64gc at various times as
well as cross tested on rv64gc more times than I can probably count (we've have
this patch internally for a while).  More importantly, I just successfully
tested it on rv64gc and rv32gcv elf configurations with the trunk

gcc/

* config/riscv/riscv-string.cc (riscv_expand_strcmp): Do not inline
strncmp with zero size.
(emit_strcmp_scalar_compare_subword): Adjust rotation for rv32 vs rv64.
* config/riscv/riscv.opt (var_inline_strcmp): Enable by default.
(vriscv_inline_strncmp, riscv_inline_strlen): Likewise.

gcc/testsuite

* gcc.target/riscv/zbb-strlen-disabled-2.c: Turn off inlining.
gcc/config/riscv/riscv-string.cc
gcc/config/riscv/riscv.opt
gcc/testsuite/gcc.target/riscv/zbb-strlen-disabled-2.c