[PATCH] Vectorizing Global Structures - Take 2

Renato Golin renato.golin at linaro.org
Fri Feb 15 01:46:15 PST 2013


On 15 February 2013 05:49, Arnold Schwaighofer <aschwaighofer at apple.com>wrote:

> struct { int A[100]; int B[100]} S;
>
> ptr = gep S, 0, 0, x
> ptr2 = gep S, 0, 1, y
>
> = load ptr, !tbaa !"structS::A"
> = load ptr2, !tbaa !"structS::B"
>
> using this you could tell that ptr and ptr2 do not alias without knowing
> about x and y. Assuming certain language guarantees, which I don't know we
> could assume :).
>

Without inspecting the induction range and step, I don't know if you can
ever say they don't alias.

C allows you to do:

A[150] = B[51];

And if you rely only on the type being different, you might say then don't
alias, when they actually do.


So for the following example it will conservatively say arrayidx and
> arrayidx2 alias?
>
> %struct.anon = type { [256 x i64], i64, [256 x i64] }
>
> define void @foo(i32 %x, i32 %y) {
>   %arrayidx = getelementptr inbounds %struct.anon* @Foo, i32 0, i32 0, i32
> %x
>   %0 = store i64* %arrayidx, align 8
>   %arrayidx2 = getelementptr inbounds %struct.anon* @Foo, i32 0, i32 2,
> i32 %y
>   %1 = store i64* %arrayidx2, align 8
> }
>

It's still valid C to do A[300] and end up reading B.

In that form, I'd never try to do anything with that function, not without
enough RT checks. ;)

--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130215/58b687e8/attachment.html>


More information about the llvm-commits mailing list