[SelectionDAG] Teach LegalizeVectorOps to directly Expand CTTZ_ZERO_UNDEF/CTLZ_ZERO_UNDEF to CTTZ/CTLZ directly if those ops are Legal/Custom instead of deferring it to LegalizeOps.

This is needed to support CTTZ/CTLZ Custom correctly since LegalizeOps would be too late to do the custom lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266951 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2016-04-21 04:43:57 +00:00
parent 0562d502ea
commit 3655b0c31f

View File

@ -1002,10 +1002,12 @@ SDValue VectorLegalizer::ExpandFNEG(SDValue Op) {
}
SDValue VectorLegalizer::ExpandCTLZ_CTTZ_ZERO_UNDEF(SDValue Op) {
// If the non-ZERO_UNDEF version is supported we can let LegalizeDAG handle.
// If the non-ZERO_UNDEF version is supported we can use that instead.
unsigned Opc = Op.getOpcode() == ISD::CTLZ_ZERO_UNDEF ? ISD::CTLZ : ISD::CTTZ;
if (TLI.isOperationLegalOrCustom(Opc, Op.getValueType()))
return Op;
if (TLI.isOperationLegalOrCustom(Opc, Op.getValueType())) {
SDLoc DL(Op);
return DAG.getNode(Opc, DL, Op.getValueType(), Op.getOperand(0));
}
// Otherwise go ahead and unroll.
return DAG.UnrollVectorOp(Op.getNode());