https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127908
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:02018d606e8ae483cdf2f5ea3f222fc582ce3090 commit r17-5785-g02018d606e8ae483cdf2f5ea3f222fc582ce3090 Author: Jeff Law <[email protected]> Date: Sun Nov 1 10:01:00 2026 -0700 [RISC-V][PR target/127908] Properly recognize additional UNSPECs that may trap for RISC-v As noted in the BZ the RISC-V port has several UNSPECs with integer modes, but which can trigger FE_INVALID or other similar exceptions. Because the UNSPECs have an integer mode, the standard may-trap hooks return false and that allows the scheduler to move things around too aggressively speculate a trapping insn up past its controlling condition. This patch introduces a suitable target override which will detect the potentially trapping UNSPECs with integer modes which in turn avoids the invalid speculation. Tested on riscv32-elf and riscv64-elf. Bootstrap on the K3 and c920 is in flight. K1 is queued. Pushing to the trunk. PR target/127908 gcc/ * config/riscv/riscv.cc (riscv_unspec_may_trap_p): New function. (TARGET_UNSPEC_MAY_TRAP_P): Define. gcc/testsuite * gcc.target/riscv/pr127908.c: New test.
