This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: FRE - SCCVN problem with initialized global variables
- From: "Daniel Berlin" <dberlin at dberlin dot org>
- To: "Andreas Krebbel" <Andreas dot Krebbel at de dot ibm dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 18 Jul 2007 15:06:55 -0400
- Subject: Re: FRE - SCCVN problem with initialized global variables
- References: <20070718165356.GA9333@blc4eb430604175.ibm.com>
On 7/18/07, Andreas Krebbel <Andreas.Krebbel@de.ibm.com> wrote:
Hi,
GCC currently doesn't bootstrap on s390x. The problem is that
gengtype is miscompiled and I suspect the fre - sccvn changes to be
the culprit.
When sccvn performs the depth-first search for uses it might reach
global variable definitions
No, global variable definitions are *never* the SSA_NAME_DEF_STMT of
anything, so it won't reach them.
We explicitly pull out initializers from variables that are:
/* Pull out any truly constant values. */
if (TREE_READONLY (rhs)
&& TREE_STATIC (rhs)
&& DECL_INITIAL (rhs)
&& valid_gimple_expression_p (DECL_INITIAL (rhs)))
return DECL_INITIAL (rhs);
This is exacfly the same set of constraints CCP uses, and my guess is
if you disable SCCVN from doing this, you will discover the same code
is generated anyway.
. If the global variable is initialized
with a value that value is taken as constant and used to replace uses
of that variable.
e.g.:
int global = 1;
int
foo (int a)
{
return a != global;
}
int
main ()
{
global = 3;
if (foo (3))
abort ();
}
becomes (compiled with -O1):
foo (a)
{
int global.0;
int D.1626;
<bb 2>:
global.0_1 = 1;
D.1626_3 = a_2(D) != global.0_1;
return D.1626_3;
}
...
This only happens where ipa-reference proves the global is readonly
and marks it TREE_READONLY
(in this case, because there are no external function calls)
HTH,
Dan