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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<[email protected]>:

https://gcc.gnu.org/g:7dc65468ed71b7e34d255e83e6087279f8431dcd

commit r14-12842-g7dc65468ed71b7e34d255e83e6087279f8431dcd
Author: Jakub Jelinek <[email protected]>
Date:   Fri Aug 7 21:20:35 2026 +0200

    gimple-range-op: Use widen method even for sqrt reverse op [PR126534]

    For glibc the target hook returns 0 for sqrt precision (i.e. 0.5ulp
    precise), but we didn't apply the +-0.5ulp widening when doing
    reverse op and so still came up with a wrong range, even with 0.5ulp
    precision certain values around 25.0 result in sqrt (x) being 5.0.
    Even if the hook returns non-zero, I'd say more reasonable handling
    of it is that it is say worst case 1ulp (or 2ulps etc.) from the
    correct result (i.e. half ulp precise), rather than just 1ulp from
    mathematically exact result.

    So, the following patch uses the newly added widen method to add
    this 0.5ulp before we feed it into frange_arithmetic.

    2026-08-07  Jakub Jelinek  <[email protected]>

            PR tree-optimization/126534
            * gimple-range-op.cc (cfn_sqrt::op1_range): Widen lb or ub
            by further 0.5ulp or 1ulp before squaring it.
            * range-op-float.cc (float_widen_lhs_range): No longer static.

            * gcc.dg/pr126534.c: New test.

    Reviewed-by: Aldy Hernandez <[email protected]>
    (cherry picked from commit 500d82452bdba0de71dae1056ccf366fa07147e9)

Reply via email to