aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-gimple.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-03-18 14:02:17 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-18 14:02:17 +0000
commitc8ae0bec3e2b25d5663f10ad4627d0636db316d8 (patch)
tree34274bc646f8291660cba602b593b220e0f0b0e1 /gcc/tree-gimple.c
parent8119fc93077ce835232c711273cd8f3b097f17f4 (diff)
downloadgcc-c8ae0bec3e2b25d5663f10ad4627d0636db316d8.zip
gcc-c8ae0bec3e2b25d5663f10ad4627d0636db316d8.tar.gz
gcc-c8ae0bec3e2b25d5663f10ad4627d0636db316d8.tar.bz2
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
Diffstat (limited to 'gcc/tree-gimple.c')
-rw-r--r--gcc/tree-gimple.c89
1 files changed, 83 insertions, 6 deletions
diff --git a/gcc/tree-gimple.c b/gcc/tree-gimple.c
index d1e47f6..93e99e6 100644
--- a/gcc/tree-gimple.c
+++ b/gcc/tree-gimple.c
@@ -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