This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RFH] Folding of &a[-1]
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 16 Feb 2005 13:31:16 +0100 (CET)
- Subject: [RFH] Folding of &a[-1]
Hi!
While trying to implement folding of &a +- cst to &a[c] I came
along the C frontend, which for
int a[4];
int *p = &a[-1];
produces
p = &a + (int *)-4;
so my new transformation gets
<integer_cst 0x401b5738 type <pointer_type 0x401559b4> constant invariant
4294967292>
as (int *)-4.
But of course trying to fold the index back into an ARRAY_REF, thereby
adjusting for the element size does not preserve the unsigned pointer
overflow behavior and I get
&a[-4U/4] from &a[-1]
which is of course not the same.
Any idea how to avoid this kind of mess and still fold &a + cst
to an ARRAY_REF if appropriate?
Thanks,
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/