Commit c8ae0bec by Richard Guenther Committed by Richard Biener

tree-gimple.h (is_gimple_invariant_address): Declare.

2008-03-18  Richard Guenther  <rguenther@suse.de>

	* tree-gimple.h (is_gimple_invariant_address): Declare.
	(is_gimple_constant): Likewise.
	* tree-gimple.c (is_gimple_constant): New function.
	(is_gimple_invariant_address): Likewise.
	(is_gimple_min_invariant): Implement in terms of is_gimple_constant
	and is_gimple_invariant_address.
	* tree-ssa-loop-niter.c (expand_simple_operations): Revert
	previous change.
	* tree-data-ref.c (get_references_in_stmt): A SSA_NAME is not
	an addressable base.

	* gcc.dg/tree-ssa/loop-19.c: Revert previous change.

From-SVN: r133311
parent 8119fc93
2008-03-18 Richard Guenther <rguenther@suse.de>
* tree-gimple.h (is_gimple_invariant_address): Declare.
(is_gimple_constant): Likewise.
* tree-gimple.c (is_gimple_constant): New function.
(is_gimple_invariant_address): Likewise.
(is_gimple_min_invariant): Implement in terms of is_gimple_constant
and is_gimple_invariant_address.
* tree-ssa-loop-niter.c (expand_simple_operations): Revert
previous change.
* tree-data-ref.c (get_references_in_stmt): A SSA_NAME is not
an addressable base.
2008-03-18 Jakub Jelinek <jakub@redhat.com>
PR middle-end/35611
......
2008-03-18 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/loop-19.c: Revert previous change.
2008-03-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/35617
......@@ -6,7 +6,7 @@
/* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-*} } */
/* { dg-require-effective-target nonpic } */
/* { dg-options "-O2 -fdump-tree-final_cleanup" } */
/* { dg-options "-O3 -fdump-tree-final_cleanup" } */
# define N 2000000
static double a[N],c[N];
......
......@@ -3965,11 +3965,14 @@ get_references_in_stmt (tree stmt, VEC (data_ref_loc, heap) **references)
if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
{
tree base;
op0 = &GIMPLE_STMT_OPERAND (stmt, 0);
op1 = &GIMPLE_STMT_OPERAND (stmt, 1);
if (DECL_P (*op1)
|| (REFERENCE_CLASS_P (*op1) && get_base_address (*op1)))
|| (REFERENCE_CLASS_P (*op1)
&& (base = get_base_address (*op1))
&& TREE_CODE (base) != SSA_NAME))
{
ref = VEC_safe_push (data_ref_loc, heap, *references, NULL);
ref->pos = op1;
......
......@@ -167,17 +167,13 @@ is_gimple_addressable (tree t)
|| INDIRECT_REF_P (t));
}
/* Return true if T is a GIMPLE minimal invariant. It's a restricted
form of function invariant. */
/* Return true if T is a valid gimple constant. */
bool
is_gimple_min_invariant (const_tree t)
is_gimple_constant (const_tree t)
{
switch (TREE_CODE (t))
{
case ADDR_EXPR:
return TREE_INVARIANT (t);
case INTEGER_CST:
case REAL_CST:
case FIXED_CST:
......@@ -198,6 +194,87 @@ is_gimple_min_invariant (const_tree t)
}
}
/* Return true if T is a gimple invariant address. */
bool
is_gimple_invariant_address (const_tree t)
{
tree op;
if (TREE_CODE (t) != ADDR_EXPR)
return false;
op = TREE_OPERAND (t, 0);
while (handled_component_p (op))
{
switch (TREE_CODE (op))
{
case ARRAY_REF:
case ARRAY_RANGE_REF:
if (!is_gimple_constant (TREE_OPERAND (op, 1))
|| TREE_OPERAND (op, 2) != NULL_TREE
|| TREE_OPERAND (op, 3) != NULL_TREE)
return false;
break;
case COMPONENT_REF:
if (TREE_OPERAND (op, 2) != NULL_TREE)
return false;
break;
default:;
}
op = TREE_OPERAND (op, 0);
}
if (CONSTANT_CLASS_P (op))
return true;
if (INDIRECT_REF_P (op))
return false;
switch (TREE_CODE (op))
{
case PARM_DECL:
case RESULT_DECL:
case LABEL_DECL:
case FUNCTION_DECL:
return true;
case VAR_DECL:
if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
&& ! DECL_DLLIMPORT_P (op))
|| DECL_THREAD_LOCAL_P (op)
|| DECL_CONTEXT (op) == current_function_decl
|| decl_function_context (op) == current_function_decl)
return true;
break;
case CONST_DECL:
if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
|| decl_function_context (op) == current_function_decl)
return true;
break;
default:
gcc_unreachable ();
}
return false;
}
/* Return true if T is a GIMPLE minimal invariant. It's a restricted
form of function invariant. */
bool
is_gimple_min_invariant (const_tree t)
{
if (TREE_CODE (t) == ADDR_EXPR)
return is_gimple_invariant_address (t);
return is_gimple_constant (t);
}
/* Return true if T looks like a valid GIMPLE statement. */
bool
......
......@@ -62,6 +62,10 @@ extern bool is_gimple_addressable (tree);
/* Returns true iff T is any valid GIMPLE lvalue. */
extern bool is_gimple_lvalue (tree);
/* Returns true iff T is a GIMPLE invariant address. */
bool is_gimple_invariant_address (const_tree);
/* Returns true iff T is a valid GIMPLE constant. */
bool is_gimple_constant (const_tree);
/* Returns true iff T is a GIMPLE restricted function invariant. */
extern bool is_gimple_min_invariant (const_tree);
/* Returns true iff T is a GIMPLE rvalue. */
......
......@@ -1436,10 +1436,6 @@ expand_simple_operations (tree expr)
return expr;
e = GIMPLE_STMT_OPERAND (stmt, 1);
/* Do not expand random invariants. */
if (TREE_INVARIANT (e)
&& !is_gimple_min_invariant (e))
return expr;
if (/* Casts are simple. */
TREE_CODE (e) != NOP_EXPR
&& TREE_CODE (e) != CONVERT_EXPR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment