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

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

https://gcc.gnu.org/g:746bdda47afbbe4b7cf5581e1f6d86824fdc10b6

commit r17-2076-g746bdda47afbbe4b7cf5581e1f6d86824fdc10b6
Author: Kaz Kojima <[email protected]>
Date:   Fri Oct 18 11:09:37 2024 +0900

    LRA: Add cannot_substitute_const_equiv_p target hook

    On SH fp constant load special instructions 'fldi0' and 'fldi1' are only
valid
    for single-precision fp mode and thus depend on mode-switiching.  LRA is
    not aware of that (or any mode-switching constraints) and would emit such
    constant loads in the wrong mode by changing fp-move related insn
alternative
    without validating fp-mode attributes.

    This new target hook allows rejecting such potentially unsafe
substitutions.

    This patch has been proposed here
    https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709649.html

    but was initially rejected, as it's just papering over the real problem.
    Further discussion has clarified that this is a general issue in GCC, not
only
    limited to LRA.  Everything that runs after the mode-switching pass
    can make potentially unsafe insn transformations because nothing is
validating
    the insn mode requirements against the current cpu/fpu mode state.

    After some reconsideration, this patch was approved
    https://gcc.gnu.org/pipermail/gcc-patches/2026-June/722024.html

    gcc/ChangeLog:
            PR target/117182
            PR target/55212
            * target.def (cannot_substitute_const_equiv_p): New target hook.
            * doc/tm.texi.in: Add it.
            * lra-constraints.cc (get_equiv): Use it.
            * config/sh/sh.cc (sh_cannot_substitute_const_equiv_p): Override
it.
            * doc/tm.texi: Re-generate.

Reply via email to