public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110204] [14 Regression] Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior)
Date: Wed, 19 Jul 2023 13:12:49 +0000 [thread overview]
Message-ID: <bug-110204-4-akNQCd8uL5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110204-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110204
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> Yeah, the issue is that PRE figures out a new value here but we've already
> done value-numbering so we can't alter the "old" solution here. So what we
> do
> is add a '0' with value '_42' (instead of value '0'). This "second order"
> value numbering leaves more opportunities on the plate. It was IMHO
> cleaner to insert a
>
> pretmp_163 = 0;
>
> than substituting '0' everywhere but then leaving around the third order
> optimizations in case we had _42 + 1 that would then simplify to sth = 1 ...
>
> Previously we'd have inserted a degenerate PHI, now we get these kind of
> copies. "Now" is for a long time so this isn't new for PRE at least.
>
> We could "hack" this by doing
>
> diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
> index 11061a374a2..effb4f4de73 100644
> --- a/gcc/tree-ssa-sccvn.cc
> +++ b/gcc/tree-ssa-sccvn.cc
> @@ -6615,6 +6615,13 @@ eliminate_dom_walker::eliminate_push_avail
> (basic_block, tree op)
> if (avail[SSA_NAME_VERSION (valnum)])
> pushop = avail[SSA_NAME_VERSION (valnum)];
> avail_stack.safe_push (pushop);
> + if (gassign *ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (op)))
> + if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
> + {
> + tree rhs1 = gimple_assign_rhs1 (ass);
> + if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
> + op = rhs1;
> + }
> avail[SSA_NAME_VERSION (valnum)] = op;
> }
> }
Ah, that breaks the avail stack handling. We can do the trick in
eliminate_avail though where it's more expensive or make the avail
stack more complicated.
next prev parent reply other threads:[~2023-07-19 13:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-10 14:41 [Bug c++/110204] New: " jun at junz dot org
2023-06-10 15:54 ` [Bug tree-optimization/110204] " pinskia at gcc dot gnu.org
2023-06-10 15:54 ` [Bug tree-optimization/110204] [14 Regression] " pinskia at gcc dot gnu.org
2023-07-15 3:34 ` pinskia at gcc dot gnu.org
2023-07-15 3:48 ` pinskia at gcc dot gnu.org
2023-07-15 3:56 ` pinskia at gcc dot gnu.org
2023-07-17 9:55 ` rguenth at gcc dot gnu.org
2023-07-19 13:12 ` rguenth at gcc dot gnu.org [this message]
2023-07-20 12:46 ` cvs-commit at gcc dot gnu.org
2023-07-20 12:55 ` 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-110204-4-akNQCd8uL5@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).