[LLVMdev] type legalizer promoting BUILD_VECTORs

Bob Wilson bob.wilson at apple.com
Tue Feb 3 09:02:58 PST 2009


On Feb 2, 2009, at 1:22 PM, Duncan Sands wrote:
> another way this could be done is to say that the operands of a
> BUILD_VECTOR don't have to have the same type as the element type
> of the built vector.  Then when the type legalizer sees a
> v4i16 = BUILD_VECTOR(i16, i16, i16, i16) it can turn this into a
> v4i16 = BUILD_VECTOR(i32, i32, i32, i32) and it will be happy
> (all result and operand types are legal).  This requires changing
> the definition of BUILD_VECTOR slightly.  Targets will need to
> understand that only the bottom 16 bits of the operands are to
> be used, but I doubt that's a problem.  Would this solve your
> problem?

That might be good.  An alternative would be to leave the current  
definition of BUILD_VECTOR but change the type legalizer to ignore the  
BUILD_VECTOR operands.  I would prefer the latter.  Unless  the  
BUILD_VECTOR is being expanded and the individual element values need  
to be instantiated separately, I don't see why the element types would  
need to be legal on their own.  I'm new to LLVM so maybe there are  
some constraints that I don't know about.  But, it seems like if a  
target says that a particular vector type is legal and if it does not  
lower a BUILD_VECTOR of that type, then nothing more needs to be done  
to the vector elements.

>
> PS: Can you please give a concrete example where the current
> behavior causes trouble for you?

Well, at this point, I've already worked around the immediate issue.   
Changing it is not urgent.  I may or may not run into this again later  
in the project I am working on.  For now I wanted to raise the issue  
because I found the current behavior surprising and it took me a while  
to work out why it was happening.  Thanks for thinking about it.



More information about the llvm-dev mailing list