This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36201] NVR in the front-end causes missed optimization later on (<retval> thought to alias arguments)
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 May 2008 08:43:57 -0000
- Subject: [Bug middle-end/36201] NVR in the front-end causes missed optimization later on (<retval> thought to alias arguments)
- References: <bug-36201-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-05-13 08:43 -------
Confirmed on 32bit targets.
SMT.6, UID D.1708, struct a, is addressable, is global, score: 320004, direct
reads: 0, direct writes: 0, indirect reads: 2, indirect writes: 0, call
clobbered (is global var, is incoming pointer), may aliases: { <retval> }
<retval>, UID D.1678, struct a, is addressable, score: 1280052, direct reads:
2, direct writes: 2, indirect reads: 2, indirect writes: 0, call clobbered (is
global var, is incoming pointer)
It's easy to hack flow-insensitive aliasing to say that RESULT_DECL isn't
really
addressable (which is the difference here I believe) - but it is harder to
argue that this doesn't ever go wrong ;)
With that we get
a f(a&, a&) (struct a & g, struct a & h)
{
long long int pretmp.12;
<bb 2>:
pretmp.12 = h->b;
<retval>.b = (pretmp.12 + g->b) + pretmp.12 * 1023;
return <retval>;
}
Now onto why the following is safe...
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c (revision 135255)
+++ tree-ssa-alias.c (working copy)
@@ -3338,6 +3338,10 @@ debug_may_aliases_for (tree var)
bool
may_be_aliased (tree var)
{
+ /* Nothing can alias the result decl. */
+ if (TREE_CODE (var) == RESULT_DECL)
+ return false;
+
/* Obviously. */
if (TREE_ADDRESSABLE (var))
return true;
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC target triplet| |i?86-*-*
Last reconfirmed|0000-00-00 00:00:00 |2008-05-13 08:43:57
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36201