public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107569] [13 Regression] Failure to optimize std::isfinite since r13-3596
Date: Thu, 10 Nov 2022 11:34:07 +0000 [thread overview]
Message-ID: <bug-107569-4-32PKgbjqpN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107569-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107569
--- Comment #24 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #22)
> Folding statement: _2 = __builtin_pow (1.0e+1, _1);
> Global Exported: _2 = [frange] double [0.0 (0x0.0p+0), +Inf] +NAN
> The +NAN looks suspicious, shouldn't that be +-NAN ?
> Of course once we handle POW builtins, if we are smart enough we should see
> that it is 10.0 ** [INT_MIN, -1] and so [0.0, 1.0e-1] (plus some larger ulp
> error because library functions aren't exactly 0.5ulp precise all the time).
> But when we don't know what __builtin_pow does (from frange perspective), I
> don't see what
> tells us that NAN with negative sign can't appear.
Yeah, that +NAN looks very suspicious. For that matter, it took me a while to
figure out how we know that _2 can't be negative, because we don't have any
range-op entries for __builtin_pow.
So...here's a trick to figure this out: --param=ranger-debug=tracegori
You'll see in the *evrp dump:
Folding statement: _2 = __builtin_pow (1.0e+1, _1);
45 range_of_stmt (_2) at stmt _2 = __builtin_pow (1.0e+1, _1);
TRUE : (45) range_of_stmt (_2) [frange] double [0.0 (0x0.0p+0), +Inf]
+NAN
46 range_of_expr(_1) at stmt _2 = __builtin_pow (1.0e+1, _1);
TRUE : (46) range_of_expr (_1) [frange] double VARYING +-NAN
47 range_of_stmt (_2) at stmt _2 = __builtin_pow (1.0e+1, _1);
TRUE : (47) cached (_2) [frange] double [0.0 (0x0.0p+0), +Inf] +NAN
Global Exported: _2 = [frange] double [0.0 (0x0.0p+0), +Inf] +NAN
So ranger was able to figure out immediately that _2 was positive.
Andrew added smarts to break into any given place, so we can break where the
counter is 45:
(gdb) break breakpoint if index == 45
Yes, amazingly there's only one function named breakpoint() in the entire
compiler ;-).
If you single step from there on, we run into:
if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p))
r.set_nonnegative (type);
else if (gimple_call_nonnull_result_p (call)
|| gimple_call_nonnull_arg (call))
r.set_nonzero (type);
else
r.set_varying (type);
IIRC, we had some discussion upstream about the meaning of set_nonnegative, and
we all agreed that nuking -NAN was the right thing. Neat, huh? :)
next prev parent reply other threads:[~2022-11-10 11:34 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 12:09 [Bug tree-optimization/107569] New: " jakub at gcc dot gnu.org
2022-11-08 12:09 ` [Bug tree-optimization/107569] " jakub at gcc dot gnu.org
2022-11-08 12:59 ` pilarlatiesa at gmail dot com
2022-11-08 13:30 ` rguenth at gcc dot gnu.org
2022-11-08 13:34 ` jakub at gcc dot gnu.org
2022-11-08 14:46 ` amacleod at redhat dot com
2022-11-08 14:53 ` jakub at gcc dot gnu.org
2022-11-08 15:14 ` amacleod at redhat dot com
2022-11-08 15:34 ` jakub at gcc dot gnu.org
2022-11-08 15:53 ` amacleod at redhat dot com
2022-11-08 15:55 ` jakub at gcc dot gnu.org
2022-11-08 16:00 ` jakub at gcc dot gnu.org
2022-11-08 17:25 ` jakub at gcc dot gnu.org
2022-11-09 14:20 ` aldyh at gcc dot gnu.org
2022-11-09 14:27 ` aldyh at gcc dot gnu.org
2022-11-09 14:30 ` aldyh at gcc dot gnu.org
2022-11-09 15:01 ` pilarlatiesa at gmail dot com
2022-11-09 15:10 ` jakub at gcc dot gnu.org
2022-11-09 15:38 ` jakub at gcc dot gnu.org
2022-11-09 17:21 ` cvs-commit at gcc dot gnu.org
2022-11-09 18:21 ` jakub at gcc dot gnu.org
2022-11-10 9:32 ` aldyh at gcc dot gnu.org
2022-11-10 9:36 ` jakub at gcc dot gnu.org
2022-11-10 10:22 ` jakub at gcc dot gnu.org
2022-11-10 10:29 ` jakub at gcc dot gnu.org
2022-11-10 10:40 ` jakub at gcc dot gnu.org
2022-11-10 11:34 ` aldyh at gcc dot gnu.org [this message]
2022-11-10 11:34 ` aldyh at gcc dot gnu.org
2022-11-10 12:22 ` jakub at gcc dot gnu.org
2022-11-10 12:47 ` aldyh at gcc dot gnu.org
2022-11-10 12:54 ` jakub at gcc dot gnu.org
2022-11-10 13:19 ` aldyh at gcc dot gnu.org
2022-11-10 13:35 ` aldyh at gcc dot gnu.org
2022-11-10 16:12 ` jakub at gcc dot gnu.org
2022-11-10 17:50 ` aldyh at gcc dot gnu.org
2022-11-10 19:14 ` aldyh at gcc dot gnu.org
2022-11-10 19:29 ` jakub at gcc dot gnu.org
2022-11-11 7:15 ` aldyh at gcc dot gnu.org
2022-11-12 8:42 ` cvs-commit at gcc dot gnu.org
2022-11-12 8:42 ` cvs-commit at gcc dot gnu.org
2022-11-12 8:43 ` cvs-commit at gcc dot gnu.org
2022-11-30 1:43 ` romain.geissler at amadeus dot com
2022-12-08 16:24 ` jakub at gcc dot gnu.org
2022-12-08 16:32 ` jakub at gcc dot gnu.org
2022-12-08 16:37 ` jakub at gcc dot gnu.org
2022-12-09 15:34 ` amacleod at redhat dot com
2023-02-27 10:07 ` rguenth at gcc dot gnu.org
2023-03-22 15:26 ` jakub at gcc dot gnu.org
2023-03-22 16:07 ` jakub at gcc dot gnu.org
2023-03-23 8:38 ` jakub at gcc dot gnu.org
2023-03-23 13:47 ` rguenth at gcc dot gnu.org
2023-03-23 14:30 ` jakub at gcc dot gnu.org
2023-03-23 16:22 ` cvs-commit at gcc dot gnu.org
2023-03-23 16:22 ` rguenth 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-107569-4-32PKgbjqpN@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).