https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116256
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <l...@gcc.gnu.org>: https://gcc.gnu.org/g:59e5d086a348f2b9e5adae1ba820ba7aaf7289db commit r15-7080-g59e5d086a348f2b9e5adae1ba820ba7aaf7289db Author: Jeff Law <j...@ventanamicro.com> Date: Mon Jan 20 14:35:59 2025 -0700 [PR target/116256] Fix latent regression in pattern to associate arithmetic to simplify constants This is something I spotted working on an outstanding issue with pr116256. It's a latent regression. I'm reasonably sure that with some effort I could find a testcase that would represent a regression, probably just by adjusting the constant index in "f" within in gcc.c-torture/execute/index-1.c We have to define_insn_and_split patterns that potentially reassociate shifts and adds to make a constant term cheaper to synthesize. The split code for these two patterns assumes that if the left shifted constant is cheaper than the right shifted constant then the left shifted constant can be loaded with a trivial set. That is not always the case -- and we'll ICE. This patch simplifies the matching condition so that it only matches when the constant can be loaded with a single instruction. Tested in my tester on rv32 and rv64. Will wait for precommit CI to render a verdict. Jeff PR target/116256 gcc/ * config/riscv/riscv.md (reassocating constant addition): Adjust condition to avoid creating an unrecognizable insn.