From a7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Sat, 10 Jul 2004 06:57:58 +0200 Subject: tree-ssa-loop-im.c: New file. * tree-ssa-loop-im.c: New file. * Makefile.in (tree-ssa-loop-im.o): Add. * cfgloop.c (superloop_at_depth): New function. * cfgloop.h (superloop_at_depth): Declare. * common.opt (ftree-lim): New flag. * expr.c (array_ref_up_bound): New function. * params.def (PARAM_LIM_EXPENSIVE): New parameter. * timevar.def (TV_LIM): New timevar. * tree-dfa.c (compute_immediate_uses): Respect TDFA_USE flags when computing immediate uses of a phi node. * tree-flow.h (struct tree_ann_common_d): Add aux field. (loop_commit_inserts, for_each_index, tree_ssa_lim): Declare. * tree-optimize.c (init_tree_optimization_passes): Add pass_lim. * tree-pass.h (pass_lim): Declare. * tree-ssa-loop.c (tree_ssa_loop_im, gate_tree_ssa_loop_im): New functions. (pass_lim): New pass structure. * tree-eh.c (tree_could_trap_p): Handle ARRAY_REFs correctly. * tree.c (in_array_bounds_p): New function. * tree.h (TREE_THIS_NOTRAP): Define also for ARRAY_REFs. (in_array_bounds_p, array_ref_up_bound): Declare. * doc/invoke.texi (-ftree-lim, --param lim-expensive): Document. * doc/passes.texi (tree-ssa-loop-im.c): Document. From-SVN: r84441 --- gcc/expr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/expr.c') diff --git a/gcc/expr.c b/gcc/expr.c index c390f54..6cd22b8 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5706,6 +5706,23 @@ array_ref_low_bound (tree exp) return fold_convert (TREE_TYPE (TREE_OPERAND (exp, 1)), integer_zero_node); } +/* Return a tree representing the upper bound of the array mentioned in + EXP, an ARRAY_REF. */ + +tree +array_ref_up_bound (tree exp) +{ + tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0))); + + /* If there is a domain type and it has an upper bound, use it, substituting + for a PLACEHOLDER_EXPR as needed. */ + if (domain_type && TYPE_MAX_VALUE (domain_type)) + return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp); + + /* Otherwise fail. */ + return NULL_TREE; +} + /* Return a tree representing the offset, in bytes, of the field referenced by EXP. This does not include any offset in DECL_FIELD_BIT_OFFSET. */ -- cgit v1.1