https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128966

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Matt Turner <[email protected]>:

https://gcc.gnu.org/g:e59802da2591cbc4af712758681e5607e9688662

commit r17-7043-ge59802da2591cbc4af712758681e5607e9688662
Author: Matt Turner <[email protected]>
Date:   Mon Nov 23 16:49:09 2026 -0500

    ia64: Disallow RFmode mode changes in FR registers [PR128966]

    ia64 caller-saves FR registers in RFmode, so LRA restores a value
    with ldf.fill into (reg:RF fN) while later instructions use
    (reg:XF fN), (reg:DF fN) or (reg:SF fN).  late-combine can propagate
    the restore into such a use, because REG_CAN_CHANGE_MODE_P says the
    mode change is valid and simplify_subreg then turns
    (subreg:DF (mem:RF slot)) into (mem:DF slot).  The slot holds the
    82-bit register image written by stf.spill, but ldfd, ldfs and ldfe
    read the memory format, so the value is corrupted.

    Reject mode changes between RFmode and other modes in FR registers, as
    ia64_can_change_mode_class already does for changes between FP and
    integer modes.  This does not stop LRA from caller-saving FP values in
    RFmode with stf.spill and ldf.fill.  Across gcc.target/ia64 and
    gcc.c-torture at -O2 and -Os, the only other code change is an extra
    pair of FR moves in gcc.c-torture/compile/20030904-1.c, where
    cprop_hardreg can no longer reuse an RFmode division result as DFmode.

    This also fixes gcc.dg/torture/builtin-complex-1.c at -Os, and
    type-punning an __fpreg as a long double at -O2.  That used to return
    the FR register unchanged; it now does stf.spill and ldfe, as -O0 does.
    pr128966-2.c tests it.

            PR target/128966

    gcc/ChangeLog:

            * config/ia64/ia64.cc (ia64_can_change_mode_class): Reject mode
            changes between RFmode and other modes in FR registers.

    gcc/testsuite/ChangeLog:
            * gcc.target/ia64/pr128966.c: New test.
            * gcc.target/ia64/pr128966-2.c: New test.

Reply via email to