On 11/19/26 10:14 PM, Jin Ma wrote:
Set the jump-table threshold to 11 when optimizing for speed on C9501
and SpacemiT X100 (K3).  The eight-way character set dispatch in
CPython 3.11.15 then uses conditional branches, avoiding a table load
and an indirect jump.  Keep the generic threshold for other cores and
for functions compiled with -Os or -Oz.

Keep the eight-way switch in pr126236.c eligible for a jump table so
the test continues to exercise vsetvl on shared jump-table edges.

PyBench relative gains are positive when elapsed time decreases.

   Case                             K3    C9501
   --------------------------  -------  -------
   Geomean (58 cases)           +0.89%   +1.35%

Cases that ran more than 5% faster or slower on C9501

   Case                             K3    C9501
   --------------------------  -------  -------
   CompareUnicode               +1.57%  +14.02%
   UnicodeSlicing               -1.53%  +12.21%
   CompareFloats               +17.54%  +10.84%
   CreateStringsWithConcat      -2.68%  +10.38%
   StringSlicing                -1.85%  +10.32%
   CreateUnicodeWithConcat      -3.17%   +9.97%
   TryExcept                   -13.45%   +9.76%
   SmallLists                   +1.33%   +5.34%
   CompareIntegers             +26.47%   +5.30%
   ComplexPythonFunctionCalls   +0.67%   -5.26%

SPEC CPU2017 Integer testing on C9501 showed only a very small gain,
mainly in perlbench_r, with no clear overall regression.

Assisted-by: qwenwork

gcc/ChangeLog:

        * config/riscv/riscv.cc (riscv_tune_param): Add case_values_threshold.
        (generic_ooo_tune_info): Use the generic threshold.
        (xt_c9501_tune_info, spacemit_x100_tune_info): Use 11.
        (riscv_case_values_threshold): New function.
        (TARGET_CASE_VALUES_THRESHOLD): Define.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/case-values-threshold-1.c: New test.
        * gcc.target/riscv/case-values-threshold-2.c: New test.
        * gcc.target/riscv/case-values-threshold-3.c: New test.
        * gcc.target/riscv/case-values-threshold-4.c: New test.
        * gcc.target/riscv/case-values-threshold-5.c: New test.
        * gcc.target/riscv/case-values-threshold-6.c: New test.
        * gcc.target/riscv/rvv/vsetvl/pr126236.c: Keep the shared jump table.
---
Changes since v1

Select the speed threshold from the per-core tuning data as Jeff
suggested.  Set it to 11 for C9501 and SpacemiT X100 (K3).  Add tests
for the Rocket default and the boundaries of the speed threshold.
Only pr126236.c needs to request a jump table to exercise the shared
dispatch edges.

Tested the affected cases on rv32gcv/ilp32d and rv64gcv/lp64d with
Rocket, C9501 and SpacemiT X100 tuning, including pr126236.c under QEMU.
The six new tests passed in all six configurations.  The scan failures
in vlmax_back_prop-4.c also reproduced with the unpatched RISC-V backend.
LGTM and Sashiko clean.  OK for the trunk.

jeff

Reply via email to