This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] ARRAY_REF on pointers and more
- From: Chris Lattner <clattner at apple dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 5 May 2009 09:31:14 -0700
- Subject: Re: [PATCH][RFC] ARRAY_REF on pointers and more
- References: <alpine.LNX.2.00.0905041256280.25789@zhemvz.fhfr.qr>
On May 4, 2009, at 3:57 AM, Richard Guenther wrote:
This patch tries to address the fact that our optimization
capabilities
are weaker for array like accesses through pointers than through real
array accesses. The problem and suggestions for solutions came up in
the past as "array-ref on pointers" or also in the context of
designing
new memory reference trees on the mem-ref branch.
Hi Richard,
This is similar to a problem we have in the llvm-gcc front-end. My
solution there was to just hack ARRAY_REF to directly allow a pointer
as the first operand. The semantics are that ARRAY_REF(ptr, i) ->
*(ptr+i) - i.e. that the scale of the index stays implicit. This
actually required surprisingly few changes throughout the tree level
of the compiler to support, but we didn't update tree-ssa or any of
the RTL stuff to adjust for the change.
With this change, pointer arithmetic can be directly lowered into the
LLVM getelementptr instruction, which is how LLVM also represents
array addressing.
-Chris