This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] rfa: fix problem with reassociating pointer additions
- From: Roger Sayle <roger at eyesopen dot com>
- To: Eric Christopher <echristo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Oct 2004 19:09:40 -0600 (MDT)
- Subject: Re: [patch] rfa: fix problem with reassociating pointer additions
On Mon, 4 Oct 2004, Eric Christopher wrote:
> z = (int *) (a + (b + sizeof (c)));
>
> We end up reassociating the constant addition into either
>
> (a+(sizeof (c))) + b or
> (a+b) + sizeof(c).
>
> either could be a problem when dealing with pointer arithmetic near
> the boundaries of addressable memory.
Could you explain how this could be a problem near the boundaries of
addressable memory? A failing testcase perhaps.
I'll admit that there may be some benefits for preserving REG_POINTER
on hppa and ia64, though we do loose optimizations opportunities due
to non-longer canonicalizing addition trees to always place the constant
at the top-right. In your example, it should always become "(a+b) + C".
But I think its important to get the motivation for this patch straight,
before deciding to approve or reject it. There may be some other bug in
the compiler that this change is papering over.
Roger
--