This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
About the is_gimple_min_invariant predicate
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 4 Jul 2007 11:29:01 +0200
- Subject: About the is_gimple_min_invariant predicate
Ada bootstrap has been broken by the SCC value numbering patch too (this is PR
tree-optimization/32589) but this might be due to a latent problem.
In the FRE dump:
RHS &p__name_buffer[1]{lb: 1 sz: 1} + n_32 simplified to
&p__name_buffer[(<unnamed-signed:32>) MAX_EXPR <D.738_31, 0> + 1]{lb: 1 sz:
1} has constants 0
and the latter expression is caught by the GIMPLE expression verifier:
error: invalid array index (<unnamed-signed:32>) MAX_EXPR <D.738_31, 0> + 1;
FRE computes the remplacement in simplify_binary_expression:
/* Make sure result is not a complex expression consiting
of operators of operators (IE (a + b) + (a + c))
Otherwise, we will end up with unbounded expressions if
fold does anything at all. */
if (result)
{
if (is_gimple_min_invariant (result))
return result;
The expression
&p__name_buffer[(<unnamed-signed:32>) MAX_EXPR <D.738_31, 0> + 1]
is_gimple_min_invariant because it is TREE_INVARIANT. TREE_INVARIANT is
correct because the semantics of Ada for IN parameters guarantees that the
index is TREE_INVARIANT and p__name_buffer is a global variable.
I'm therefore wondering whether is_gimple_min_invariant should return true for
this kind of expressions.
/* Return true if T is function invariant. Or rather a restricted
form of function invariant. */
bool
is_gimple_min_invariant (tree t)
{
switch (TREE_CODE (t))
{
case ADDR_EXPR:
return TREE_INVARIANT (t);
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
case COMPLEX_CST:
case VECTOR_CST:
return true;
/* Vector constant constructors are gimple invariant. */
case CONSTRUCTOR:
if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
return TREE_CONSTANT (t);
else
return false;
default:
return false;
}
}
I think that the head comment is a little confusing: is it a formal predicate
of the GIMPLE grammar, as most of its uses would suggest, e.g.
/* Return true if T is a GIMPLE rvalue, i.e. an identifier or a constant. */
bool
is_gimple_val (tree t)
{
/* Make loads from volatiles and memory vars explicit. */
if (is_gimple_variable (t)
&& is_gimple_reg_type (TREE_TYPE (t))
&& !is_gimple_reg (t))
return false;
/* FIXME make these decls. That can happen only when we expose the
entire landing-pad construct at the tree level. */
if (TREE_CODE (t) == EXC_PTR_EXPR || TREE_CODE (t) == FILTER_EXPR)
return true;
return (is_gimple_variable (t) || is_gimple_min_invariant (t));
}
or does it have really something to do with TREE_INVARIANT trees?
--
Eric Botcazou