https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128997
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |law at gcc dot gnu.org
Last reconfirmed| |2026-11-25
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Interesting bug. Bisection landed on the change that twiddled logical op short
circuiting for riscv. But that's just the trigger, I suspect the real
underlying bug is a long latent CSE issue.
SUBREG_PROMOTED_VAR_P is effectively global state on the REG to which is has
been applied. cse.cc is copy propagating one register in place of another,
inside a SUBREG expression with promoted state. In this testcase that copy
propagation results results in breaking the contract of SUBREG_PROMOTED_VAR_P.
That in turn leads combine to believe a particular object only as 16 nonzero
bits in the lowest positions. That object is then right shifted 16 positions
resulting in 0. That 0 then const-propagates to the printf.
I think the solution here is just to wipe the promoted state when cse does this
transformation, but I want to think on it overnight.