This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR35607, another revenge of invariant addresses (ivopts)
On 03/17/08 09:27, Richard Guenther wrote:
+ /* 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 (t))
+ {
+ switch (TREE_CODE (t))
+ {
+ case ARRAY_REF:
+ case ARRAY_RANGE_REF:
+ if (!is_gimple_constant (TREE_OPERAND (t, 1))
+ || TREE_OPERAND (t, 2) != NULL_TREE
+ || TREE_OPERAND (t, 3) != NULL_TREE)
+ return false;
+ break;
+
+ case COMPONENT_REF:
+ if (TREE_OPERAND (t, 2) != NULL_TREE
+ || TREE_OPERAND (t, 3) != NULL_TREE)
+ return false;
+ break;
+
+ default:;
+ }
+ op = TREE_OPERAND (t, 0);
+ }
+
+ return TREE_INVARIANT (op);
This looks wrong. It will return false for '&a' where 'a' is a local
variable. I think I would rather move the logic from
recompute_tree_invariant_for_addr_expr. This needs to handle statics
and TLS objects.
+ }
+
+ /* 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);
You mean is_gimple_const() here.