https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108764
Bug ID: 108764 Summary: [RISCV] Cost model for RVB is too aggressive Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: sinan.lin at linux dot alibaba.com Target Milestone: --- The cost model of instructions like shNadd, add.uw, ... are set to COSTS_N_INSNS (1), which brings bad codegen in some cases. Here is a test case for the problem. ``` #include <stdint.h> int64_t foo (void * ptr, int value, int64_t num); int64_t clear1 (int64_t *array, int64_t *end, int64_t size) { return array + size < end ? foo(array, 0, size * 8) : 0; } ``` generates asm with -march=rv64gc_zba -O3 ``` clear1: slli a4,a2,3 sh3add a5,a2,a0 bgtu a1,a5,.L4 li a0,0 ret .L4: mv a2,a4 li a1,0 tail foo ``` generates asm with -march=rv64gc -O3 ``` clear1: slli a2,a2,3 add a5,a0,a2 bgtu a1,a5,.L4 li a0,0 ret .L4: li a1,0 tail foo ```