This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] ARRAY_REF on pointers and more

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]