https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117947
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
Known to fail| |14.1.0
Summary|[14/15/16 Regression] GCC |[14 Regression] GCC
|miscompile rvv intrinsics |miscompile rvv intrinsics
|at `-O2` and `-O3`, use |at `-O2` and `-O3`, use
|`vlenb` after an |`vlenb` after an
|inappropriate `vsetvli` |inappropriate `vsetvli`
CC| |rdapp at gcc dot gnu.org
Known to work| |15.1.0
--- Comment #4 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Hmm, another one that slipped past Robin and myself.
If I go back to gcc-14.2.0:
2.00 6.00 12.00 20.00 30.00 42.00 56.00 72.00 90.00 110.00 132.00 156.00 182.00
210.00 240.00 272.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 1122.00 1190.00 1260.00 1332.00 1406.00 1482.00
1560.00 1640.00 1722.00 1806.00 1892.00 1980.00 2070.00 2162.00 2256.00 2352.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
4288.00 4424.00 4556.00 4692.00 4832.00 4968.00 5112.00 5256.00 5400.00 5552.00
5700.00 5852.00 6008.00 6160.00 6320.00 6480.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 9504.00 9704.00 9904.00
10096.00
So something is clearly different. Your data matches -O0 as well as LLVM's
output on the original testcase.
Bisection points to this patch as changing the behavior:
commit 8d577a01cdbe02a23724b710b579b7811c983c33
Author: Jin Ma <[email protected]>
Date: Mon Jan 13 11:15:55 2025 -0700
RISC-V: Fix the result error caused by not updating ratio when using
"use_max_sew" to merge vsetvl
When the vsetvl instructions of the two RVV instructions are merged
using "use_max_sew", it is possible to update the sew of prev if
prev.sew < next.sew, but keep the original ratio, which is obviously
wrong. when the subsequent instructions are equal to the wrong ratio,
it is possible to generate the wrong "vsetvli zero,zero" instruction,
which will lead to unknown avl.
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (demand_system::use_max_sew): Also
set the ratio for PREV.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/bug-10.c: New test.
That patch is clearly a bugfix and in the right space given the analysis done
by Elara. I'm highly inclined to believe this was fixed. Closing. Elara can
re-open with correct output if that decision is believed to be in error.