On Fri, Jul 20, 2012 at 12:17 PM, Tobias Burnus <bur...@net-b.de> wrote: > On 07/20/2012 11:52 AM, Mikael Morin wrote >> >> OK. > > > Thanks for the review. > > >> I guess the division will be dropped too (the middle-end does the >> reverse multiplication implicitly in the pointer arithmetic). >> I wonder which one is faster (the casts in the second version are >> certainly not nice for the middle-end): >> >> ptr + (offset_in_bytes / elt_size_in_bytes) >> VS >> (sometype *) (((char *)ptr) + offset_in_bytes) > > > As we have to support strides which aren't multiples of the element size, we > have to use the second form. We currently do so for BT_CLASS but not for > BT_TYPE. Actually, half of the remaining failures on the branch seem to be > due to the wrong usage of stride- vs. byte-based offsets. For instance in > SELECT TYPE .. TYPE IS, where one has a BT_TYPE and which fails. > > I think the conversion to byte offsets will be the next step. Afterwards, we > should get rid of the offset.
The middle-end POINTER_PLUS_EXPR requires byte offsets for all pointer types, so you can avoid the conversion to char * if ptr is already a pointer type. Richard. > Tobias