aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivopts.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2006-05-01 15:07:25 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2006-05-01 15:07:25 +0000
commitea6431202d7e3c472f6c039bbfc0c22f2e8e9a52 (patch)
tree18fe0f5c1c17a977a97040b0f6c41c4d08816eac /gcc/tree-ssa-loop-ivopts.c
parentd814595c2c47096eb70ff15fffadc5218806aaec (diff)
downloadgcc-ea6431202d7e3c472f6c039bbfc0c22f2e8e9a52.zip
gcc-ea6431202d7e3c472f6c039bbfc0c22f2e8e9a52.tar.gz
gcc-ea6431202d7e3c472f6c039bbfc0c22f2e8e9a52.tar.bz2
re PR target/26726 (-fivopts producing out of bounds array refs)
2006-05-01 Richard Guenther <rguenther@suse.de> PR tree-optimization/26726 * tree-ssa-loop-ivopts.c (idx_find_step): Mark source of the problem ... (find_interesting_uses_address): ... we work around here by folding INDIRECT_REFs in the substituted base. * g++.dg/tree-ssa/ivopts-1.C: New testcase. From-SVN: r113414
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r--gcc/tree-ssa-loop-ivopts.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index acc8c8a..75d5407 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1376,6 +1376,9 @@ idx_find_step (tree base, tree *idx, void *data)
if (!iv)
return false;
+ /* XXX We produce for a base of *D42 with iv->base being &x[0]
+ *&x[0], which is not folded and does not trigger the
+ ARRAY_REF path below. */
*idx = iv->base;
if (!iv->step)
@@ -1547,6 +1550,17 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF);
base = build_fold_addr_expr (base);
+
+ /* Substituting bases of IVs into the base expression might
+ have caused folding opportunities. */
+ if (TREE_CODE (base) == ADDR_EXPR)
+ {
+ tree *ref = &TREE_OPERAND (base, 0);
+ while (handled_component_p (*ref))
+ ref = &TREE_OPERAND (*ref, 0);
+ if (TREE_CODE (*ref) == INDIRECT_REF)
+ *ref = fold_indirect_ref (*ref);
+ }
}
civ = alloc_iv (base, step);