aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>2004-07-10 06:57:58 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2004-07-10 04:57:58 +0000
commita7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f (patch)
tree7fd5b8c64fe84e6fadd94b6c98bdd7f62f3789a2 /gcc/tree.c
parentad6e2a18c2013863e1cf448471e1fa243403eb50 (diff)
downloadgcc-a7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f.zip
gcc-a7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f.tar.gz
gcc-a7e5372d6a8e2f12b6d9a15f71d5ad0794e6507f.tar.bz2
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
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 5e95ab6..033c851 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5650,6 +5650,34 @@ build_empty_stmt (void)
}
+/* Returns true if it is possible to prove that the index of
+ an array access REF (an ARRAY_REF expression) falls into the
+ array bounds. */
+
+bool
+in_array_bounds_p (tree ref)
+{
+ tree idx = TREE_OPERAND (ref, 1);
+ tree min, max;
+
+ if (TREE_CODE (idx) != INTEGER_CST)
+ return false;
+
+ min = array_ref_low_bound (ref);
+ max = array_ref_up_bound (ref);
+ if (!min
+ || !max
+ || TREE_CODE (min) != INTEGER_CST
+ || TREE_CODE (max) != INTEGER_CST)
+ return false;
+
+ if (tree_int_cst_lt (idx, min)
+ || tree_int_cst_lt (max, idx))
+ return false;
+
+ return true;
+}
+
/* Return true if T (assumed to be a DECL) must be assigned a memory
location. */