summaryrefslogtreecommitdiff
path: root/gcc/emit-rtl.c
diff options
context:
space:
mode:
authoraj <aj@138bc75d-0d04-0410-961f-82ee72b054a4>2002-09-08 10:41:20 +0000
committeraj <aj@138bc75d-0d04-0410-961f-82ee72b054a4>2002-09-08 10:41:20 +0000
commit97f8ce30d720df5a8ef7b32f24f177a630ab2f4b (patch)
tree55dd83715af1de496408e6e73457d8b79a04f206 /gcc/emit-rtl.c
parentd44c76e76badadb159e97d6bceb5df2ae5a8f2ac (diff)
downloadgcc-97f8ce30d720df5a8ef7b32f24f177a630ab2f4b.tar.gz
2002-09-08 Jan Hubicka <jh@suse.cz>
* emit-rtl.c (set_mem_attributes_minus_bitpos): Fix array_ref handling. * loop.c (loop_gics_reduce): Emit addition after. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56950 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r--gcc/emit-rtl.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index cf138d37259..e94fc4ec843 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1805,11 +1805,36 @@ set_mem_attributes_minus_bitpos (ref, t, objectp, bitpos)
do
{
+ tree index = TREE_OPERAND (t, 1);
+ tree array = TREE_OPERAND (t, 0);
+ tree domain = TYPE_DOMAIN (TREE_TYPE (array));
+ tree low_bound = (domain ? TYPE_MIN_VALUE (domain) : 0);
+ tree unit_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (array)));
+
+ /* We assume all arrays have sizes that are a multiple of a byte.
+ First subtract the lower bound, if any, in the type of the
+ index, then convert to sizetype and multiply by the size of the
+ array element. */
+ if (low_bound != 0 && ! integer_zerop (low_bound))
+ index = fold (build (MINUS_EXPR, TREE_TYPE (index),
+ index, low_bound));
+
+ /* If the index has a self-referential type, pass it to a
+ WITH_RECORD_EXPR; if the component size is, pass our
+ component to one. */
+ if (! TREE_CONSTANT (index)
+ && contains_placeholder_p (index))
+ index = build (WITH_RECORD_EXPR, TREE_TYPE (index), index, t);
+ if (! TREE_CONSTANT (unit_size)
+ && contains_placeholder_p (unit_size))
+ unit_size = build (WITH_RECORD_EXPR, sizetype,
+ unit_size, array);
+
off_tree
= fold (build (PLUS_EXPR, sizetype,
fold (build (MULT_EXPR, sizetype,
- TREE_OPERAND (t, 1),
- TYPE_SIZE_UNIT (TREE_TYPE (t)))),
+ index,
+ unit_size)),
off_tree));
t = TREE_OPERAND (t, 0);
}