public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107591] New: range-op{,-float}.cc for x * x Date: Wed, 09 Nov 2022 15:37:06 +0000 [thread overview] Message-ID: <bug-107591-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107591 Bug ID: 107591 Summary: range-op{,-float}.cc for x * x Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- int foo (int x) { if (x < -13 || x > 26) return -1; return x * x; } results in x_4(D) : [irange] int [-13, 26] _5 : [irange] int [-338, 676] That is unnecessarily pessimized, because it only computes [-13, 26] * [-13, 26] range without taking into account that both operands are the same. For the powi (x, 2) case the range is actually [0, 26 * 26], i.e. we shouldn't do a cross product for it, just compute the -13 * -13, 0 * 0 (if 0 is in the range) and 26 * 26 products and form from that the range (I admit I haven't thought about unsigned or wrapping stuff). On the PR107569 testcase it is on frange: _3 = u_2(D)->x; _6 = _3 * _3; _7 = u_2(D)->y; _8 = _7 * _7; _9 = _6 + _8; if (_9 u>= 0.0) If we don't know anything further about u_2(D)->x and u_2(D)->y, VARYING * VARYING is [0, +Inf] +-NAN, added twice is the same (note, unless -fno-signed-zeros, it should be really [+0, +Inf] +-NAN, not [-0, +Inf] +-NAN, but it doesn't matter for the u>= 0.0 comparison). And then we can fold u>= 0.0 to true.
next reply other threads:[~2022-11-09 15:37 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-09 15:37 jakub at gcc dot gnu.org [this message] 2022-11-09 15:49 ` [Bug tree-optimization/107591] " aldyh at gcc dot gnu.org 2022-11-09 15:55 ` aldyh at gcc dot gnu.org 2022-11-09 15:57 ` jakub at gcc dot gnu.org 2022-11-09 15:59 ` pinskia at gcc dot gnu.org 2022-11-09 16:01 ` pinskia at gcc dot gnu.org 2022-11-09 16:02 ` aldyh at gcc dot gnu.org 2022-11-09 16:04 ` aldyh at gcc dot gnu.org 2022-11-09 16:31 ` jakub at gcc dot gnu.org 2022-11-09 16:40 ` jakub at gcc dot gnu.org 2022-11-09 17:45 ` amacleod at redhat dot com 2022-11-09 17:49 ` jakub at gcc dot gnu.org 2022-11-09 18:22 ` amacleod at redhat dot com 2022-11-09 18:35 ` jakub at gcc dot gnu.org 2022-11-09 19:20 ` amacleod at redhat dot com 2022-11-09 20:24 ` jakub at gcc dot gnu.org 2022-11-09 20:45 ` jakub at gcc dot gnu.org 2022-11-09 22:25 ` amacleod at redhat dot com 2022-11-09 23:27 ` jakub at gcc dot gnu.org 2022-11-12 8:42 ` cvs-commit at gcc dot gnu.org 2023-04-05 7:14 ` pilarlatiesa at gmail dot com
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-107591-4@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: linkBe 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).