[LLVMdev] Altivec vs the type legalizer

Dale Johannesen dalej at apple.com
Mon Nov 9 18:11:34 PST 2009


PPC Altivec supports vector type v16i8 (and others) where the element  
type is not legal (in llvm's implementation).  When we have a  
BUILD_VECTOR of these types with constant elements, LegalizeTypes  
first promotes the element types to i32, then builds a constant pool  
entry of type v16i32.  This is wrong.  I can fix it by truncating the  
elements back to i8 in ExpandBUILD_VECTOR.  Does this seem like the  
right approach?  I ask because we'll be relying on ConstantVector::get  
and getConstantPool to work even with elements of a type that's  
illegal for the target; currently, they do.  (And I see no other way  
to fix it except to break the vector into scalars, which produces  
horrendous code.)


typedef vector unsigned char    vuint8_t;
vuint8_t baz;
void foo(vuint8_t x) {
   vuint8_t temp = (vuint8_t)(22,21,20, 3, 25,24,23, 3, 28,27,26, 3,  
31,30,29, 3);
   baz = vec_add(x, temp);
}




More information about the llvm-dev mailing list