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

--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Jeff Law <[email protected]>:

https://gcc.gnu.org/g:1067e357045b5f72b84dbd45b5e88f4d29f6232e

commit r16-9236-g1067e357045b5f72b84dbd45b5e88f4d29f6232e
Author: Icenowy Zheng <[email protected]>
Date:   Wed Jul 1 00:11:42 2026 +0800

    RISC-V: Change initial value for fmin/fmax autovec reduce [PR126049]

    Currently the auto-vectorization of C fmin()/fmax() uses
    infinity/-infinity as the initial value for reduction, which introduces
    bogus infinity values when iterating over an array with only NaNs.

    As all C fmin()/fmax(), RV F/D fmin/fmax, RVV vfmin/vfmax and RVV
    vfredmin/vfredmax are implementing the IEEE754 minimumNumber or
    maximumNumber behavior, an initial value of NaN is more suitable than
    infinity when reducing the vector (if the input vector is all NaN, the
    result will still be NaN and if the input vector contains non-NaN
    elements they will cover the initial NaN).

    Change the initial value during reduction from corresponding inf to a
    quiet NaN.

            PR target/126049

    gcc/ChangeLog:
            * config/riscv/autovec.md: Change fmin/fmax reduction initial
            value from inf/-inf to NaN for proper semantics of corresponding
            C funtion.

    gcc/testsuite/ChangeLog:
            * gcc.target/riscv/rvv/autovec/pr126049.c: New.

    (cherry picked from commit ad45faeb14a4acb551ecbb61bc1b0e1f6ce500b0)

Reply via email to