public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109008] [13 Regression] Wrong code in scipy package since r13-3926-gd4c2f1d376da6f
Date: Fri, 10 Mar 2023 09:08:52 +0000	[thread overview]
Message-ID: <bug-109008-4-Xxz4DZMdfU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109008-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #48 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r13-6574-ga1d5c729ceeb112af26e3298314a0de3058f1d82
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 10 10:07:51 2023 +0100

    range-op-float: Fix up -ffinite-math-only range extension and don't extend
into infinities [PR109008]

    The following patch does two things (both related to range extension
    around the boundaries).

    The first part (in the 2 real_isfinite blocks) is to make the ranges
    narrower when the old boundaries are minimum and/or maximum representable
    finite number.  In that case frange_nextafter gives -Inf or +Inf,
    but then the resulting computed reverse range is very far from the actually
    needed range, usually extends up to infinity or could even result in NaNs.
    While infinities are really the next representable numbers in the
    corresponding mode, REAL_VALUE_TYPE is actually a type with wider range
    for exponent and 160 bit precision, so the patch instead uses
    nextafter number in a hypothetical floating point format with the same
    mantissa precision but wider range of exponents.  This significantly
    improves the actual ranges of the reverse operations, while still making
    them conservatively correct.

    The second part is a fix for miscompilation of the new testcase below.
    For -ffinite-math-only, without this patch we extend the minimum and/or
    maximum representable finite number to -Inf or +Inf, with the patch to
    some number outside of the normal exponent range of the mode, but then
    we use set which canonicalizes it and turns the boundaries back to
    the minimum and/or maximum representable finite numbers, but because
    in say [__DBL_MAX__, __DBL_MAX__] = op1 + [__DBL_MAX__, __DBL_MAX__]
    op1 can be larger than 0, up to the largest number which rounds to even
    down back to __DBL_MAX__ and there are still no infinities involved,
    it needs to work even with -ffinite-math-only.  So, we really need to
    widen the lhs range a little bit even in that case.  The patch does
    that through temporarily clearing -ffinite-math-only, such that the
    value with infinities or the outside of bounds values passes the
    setting and verification (the VR_VARYING case is needed because
    we get ICEs otherwise, but when lhs is VR_VARYING in -ffast-math,
    i.e. minimum to maximum representable finite and both signs of NaN,
    then set does all we need, we don't need to or in a NaN range).
    We don't really later use the range in a way that would become a problem
    that it is wider than varying, we actually just perform maths on the
    two boundaries.

    As I said in the PR, this doesn't fix the !MODE_HAS_INFINITIES case,
    I believe we actually need to treat the boundary values as infinities
    in that case because they (probably) work like that, but it is unclear
    if it is just the reverse operation lhs widening that is a problem there,
    or whether it is a general problem.  I have zero experience with
    floating points without infinities (PDP11, some ARM half type?,
    what else?).

    2023-03-10  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/109008
            * range-op-float.cc (float_widen_lhs_range): If lb is
            minimum representable finite number or ub is maximum
            representable finite number, instead of widening it to
            -inf or inf widen it to negative or positive 0x0.8p+(EMAX+1).
            Temporarily clear flag_finite_math_only when canonicalizing
            the widened range.

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

  parent reply	other threads:[~2023-03-10  9:08 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 12:08 [Bug tree-optimization/109008] New: [13 Regression ]Maybe wrong " marxin at gcc dot gnu.org
2023-03-03 12:11 ` [Bug tree-optimization/109008] [13 Regression] Maybe " rguenth at gcc dot gnu.org
2023-03-03 12:14 ` rguenth at gcc dot gnu.org
2023-03-03 12:18 ` [Bug tree-optimization/109008] [13 Regression] Wrong " rguenth at gcc dot gnu.org
2023-03-03 12:24 ` rguenth at gcc dot gnu.org
2023-03-03 12:27 ` rguenth at gcc dot gnu.org
2023-03-03 12:31 ` jakub at gcc dot gnu.org
2023-03-03 12:54 ` jakub at gcc dot gnu.org
2023-03-03 13:03 ` rguenth at gcc dot gnu.org
2023-03-03 13:10 ` rguenth at gcc dot gnu.org
2023-03-03 13:14 ` rguenth at gcc dot gnu.org
2023-03-03 13:34 ` jakub at gcc dot gnu.org
2023-03-03 13:50 ` rguenth at gcc dot gnu.org
2023-03-03 14:28 ` jakub at gcc dot gnu.org
2023-03-07 12:06 ` rguenth at gcc dot gnu.org
2023-03-07 12:12 ` jakub at gcc dot gnu.org
2023-03-07 12:20 ` jakub at gcc dot gnu.org
2023-03-07 12:23 ` rguenth at gcc dot gnu.org
2023-03-07 12:25 ` rguenth at gcc dot gnu.org
2023-03-07 13:16 ` jakub at gcc dot gnu.org
2023-03-07 13:18 ` rguenth at gcc dot gnu.org
2023-03-07 13:29 ` rguenth at gcc dot gnu.org
2023-03-07 13:58 ` rguenth at gcc dot gnu.org
2023-03-07 14:10 ` rguenth at gcc dot gnu.org
2023-03-07 18:52 ` jakub at gcc dot gnu.org
2023-03-07 19:39 ` jakub at gcc dot gnu.org
2023-03-07 20:49 ` jakub at gcc dot gnu.org
2023-03-08  9:26 ` aldyh at gcc dot gnu.org
2023-03-08  9:29 ` aldyh at gcc dot gnu.org
2023-03-08  9:36 ` jakub at gcc dot gnu.org
2023-03-08 10:09 ` aldyh at gcc dot gnu.org
2023-03-08 11:29 ` jakub at gcc dot gnu.org
2023-03-08 11:30 ` jakub at gcc dot gnu.org
2023-03-08 14:51 ` jakub at gcc dot gnu.org
2023-03-08 14:52 ` jakub at gcc dot gnu.org
2023-03-08 15:07 ` jakub at gcc dot gnu.org
2023-03-08 15:54 ` jakub at gcc dot gnu.org
2023-03-08 16:37 ` jakub at gcc dot gnu.org
2023-03-08 18:56 ` jakub at gcc dot gnu.org
2023-03-08 20:02 ` jakub at gcc dot gnu.org
2023-03-09  8:52 ` cvs-commit at gcc dot gnu.org
2023-03-09 10:24 ` rguenth at gcc dot gnu.org
2023-03-09 11:06 ` jakub at gcc dot gnu.org
2023-03-09 11:12 ` marxin at gcc dot gnu.org
2023-03-09 11:50 ` jakub at gcc dot gnu.org
2023-03-09 12:34 ` rguenth at gcc dot gnu.org
2023-03-09 12:56 ` jakub at gcc dot gnu.org
2023-03-09 13:03 ` jakub at gcc dot gnu.org
2023-03-09 13:25 ` jakub at gcc dot gnu.org
2023-03-10  9:08 ` cvs-commit at gcc dot gnu.org [this message]
2023-03-10 11:41 ` cvs-commit at gcc dot gnu.org
2023-03-22  9:07 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109008-4-Xxz4DZMdfU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).