[LLVMdev] Making GEP into vector illegal?

Duncan Sands baldrick at free.fr
Wed Oct 15 10:51:20 PDT 2008


Hi Chris,

> I'm happy about factoring the code better, but a vectortype isn't an  
> arraytype (isa<ArrayType>(V) should be false).  Maybe a common base  
> class (like sequential type) would be better?

currently anything you can do with an array you can do with a vector.
So from this functional viewpoint it would make sense to have a vector
be an array with more stuff (i.e. a subclass of ArrayType).  However I
appreciate that there's a difference: a multi-element vector can be held
in a machine register, while that's not the case for an array.  But then
again, why not place first-class arrays of appropriate size in such
machine registers?  Also, at the IR level is there any practical advantage
to having vectors not be a kind of array - what does disallowing GEP win
you?  Is this entirely a codegen issue?

By the way, deriving from SequentialType doesn't make much sense to me
because SequentialType only exists to unify the types on which you can
do GEP (at least that's my understanding) - but you want to disallow GEP
on vectors!

> > From this point of view you have to allow GEP into a
> > vector; the conclusion I suppose is that codegen needs to replace
> > GEP+load or GEP+store with an extract or insert operation.
> 
> With that logic, there is no difference at all between an array and  
> vector... I disagree very strongly about this.

There is a difference of course: vectors can do more than arrays.  That's
why VectorType would derive from ArrayType :)  I understand that probably
in your head they feel different.  I say: change your head! :)

Ciao,

Duncan.



More information about the llvm-dev mailing list