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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <[email protected]>:

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

commit r17-5277-gac3b21e53c4b392e8a72b30f1c81f2339a8d6b21
Author: Igor Shevlyakov <[email protected]>
Date:   Sat Oct 17 17:39:40 2026 +0100

    simplify-rtx: Do a subreg'd vector comparison in its operands' mode
[PR127903]

    simplify_subreg turns (subreg:OUTER (cmp:INNER a b)) for a vector
    comparison into (cmp:OUTER a b), but passes INNERMODE -- the mode of the
    comparison *result* -- as the comparison mode to
    simplify_gen_relational.  That argument is the mode of the operands.
    For floating-point operands with an integer mask result, e.g.
    (subreg:V4SF (unordered:V4SI x y)), simplify_const_relational_operation
    then decides whether NaNs are honored from V4SI and folds x unord y to
    false (and x ord y to true).  On LoongArch fwprop propagates such a
    comparison into a bit-cast and the function returns zero.  Pass VOIDmode
    so the mode is taken from the operands, and add a selftest for the
    unordered/ordered case.

    The problem was found by asserting in
    simplify_const_relational_operation that MODE matches the mode of the
    operands.

    Assisted-by: Claude Opus 5.5

            PR rtl-optimization/127903

    gcc/ChangeLog:

            * simplify-rtx.cc (simplify_context::simplify_subreg): Pass
VOIDmode,
            not INNERMODE, as the comparison mode of a subreg'd vector
comparison.
            (test_vector_subreg_of_fp_comparison): New selftest.
            (test_vector_ops): Call it for float vector modes.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr127903.c: New test.

    Signed-off-by: Igor Shevlyakov <[email protected]>

Reply via email to