Currently codegen represents a vector_shuffle as a node with three operands. The third operand is a mask, which *must* be a BUILD_VECTOR node of constant integers (a different kind of node that produces a result of the right vector type isn't good enough). This causes problems during type legalization because it is not always possible to create a legal BUILD_VECTOR usable as the vector shuffle mask. (LegalizeDAG ignores the legality or not of the mask argument, but LegalizeTypes insists on legalizing the types of all nodes, which I think is the right thing to do). I think the best plan is to incorporate the mask directly into the vector shuffle node, by turning into a node with 2+N operands: the first two the same as now, followed by the N mask elements. This seems fairly straightforward to do, but involves a lot of tedious work. I don't have time for it right now so I've opened this PR in the hope that someone else will take it on :)
Would it be better to introduce a ShuffleSDNode that kept the shuffle mask as an array of integers?
In any case, either solution would be dramatically better than the current shuffle with buildvector as mask!
Lots of places want to examine masks to see if they have special properties etc. One advantage of a special node type containing the mask as a vector is that just the mask can be passed to such routines rather than the whole node (with the variadic node scheme you would have to pass the entire shuffle vector node, which is kind of sucky).
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090420/076639.html
woohoo