[LLVMdev] type legalizer promoting BUILD_VECTORs

Bob Wilson bob.wilson at apple.com
Mon Feb 2 11:31:02 PST 2009


LLVM's type legalizer is changing the types of BUILD_VECTORs in a way  
that seems wrong to me, but I'm not sure if this is a bug or if some  
targets may be relying on it.

On a 32-bit target, the default action for legalizing i8 and i16 types  
is to promote them.  If you then have a BUILD_VECTOR to construct a  
legal vector type composed of i8 or i16 values, the type legalizer  
will look at the BUILD_VECTOR operands and decide that it needs to  
promote them to i32 types.  You end up with a BUILD_VECTOR that  
constructs a vector of i32 values that are then bitcast to the  
original vector type.

This works fine for SSE, where it appears that BUILD_VECTORs are  
intentionally canonicalized to use i32 elements for the benefit of  
CSE.  I'm looking at implementing something where I think I'd like to  
keep the original vector types.  Is this behavior in the type  
legalizer something that should be changed?



More information about the llvm-dev mailing list