[LLVMdev] Altivec vs the type legalizer

Duncan Sands
2009-11-10T09:20:34Z

Hi Dale, I think Bob is right: the type legalizer shouldn't be turning v16i8
into v16i32, what should happen is that the return type of the BUILD_VECTOR
continues to be v16i8, but the type of the operands changes to i32, so you
end up with a BUILD_VECTOR that takes 16 lots of i32, and produces a v16i8.
The target then has all the info it needs to produce the best code, but needs
to be careful not the use the operand type (i32) when it really wants the vector
element type (i8).

While Bob describes this as being new rules, IIRC the old type legalizer used
to handle BUILD_VECTOR with an illegal element type needing promotion the same
way: it just promoted the operands, resulting in a mismatch between the operand
type and the vector element type (unlike in the bad old days, I believe this is
now documented as being allowed, in the description of the BUILD_VECTOR node).
However in the case of PPC I think the PPC code grabbed the BUILD_VECTOR and
transformed it before it hit this logic in the old type legalizer.  Now that
type legalization is being done first, probably this got reversed: first the
type legalizer logic transforms the BUILD_VECTOR, and only later the ppc code
gets to do its stuff.

Ciao,

Duncan.