diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index f5e8c4e..6bfb388 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -565,69 +565,12 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits, } // TODO: Can we merge SelectionDAG::GetDemandedBits into this? -// TODO: Under what circumstances can we create nodes? Constant folding? +// TODO: Under what circumstances can we create nodes? BITCAST? Constant? SDValue TargetLowering::SimplifyMultipleUseDemandedBits( SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth) const { - unsigned NumElts = DemandedElts.getBitWidth(); KnownBits LHSKnown, RHSKnown; switch (Op.getOpcode()) { - case ISD::BITCAST: { - SDValue Src = peekThroughBitcasts(Op.getOperand(0)); - EVT SrcVT = Op.getOperand(0).getValueType(); - EVT DstVT = Op.getValueType(); - unsigned NumSrcEltBits = SrcVT.getScalarSizeInBits(); - unsigned NumDstEltBits = DstVT.getScalarSizeInBits(); - - if (NumSrcEltBits == NumDstEltBits) - if (SDValue V = SimplifyMultipleUseDemandedBits( - Src, DemandedBits, DemandedElts, DAG, Depth + 1)) - return DAG.getBitcast(DstVT, V); - - // TODO - bigendian once we have test coverage. - if (SrcVT.isVector() && (NumDstEltBits % NumSrcEltBits) == 0 && - DAG.getDataLayout().isLittleEndian()) { - unsigned Scale = NumDstEltBits / NumSrcEltBits; - unsigned NumSrcElts = SrcVT.getVectorNumElements(); - APInt DemandedSrcBits = APInt::getNullValue(NumSrcEltBits); - APInt DemandedSrcElts = APInt::getNullValue(NumSrcElts); - for (unsigned i = 0; i != Scale; ++i) { - unsigned Offset = i * NumSrcEltBits; - APInt Sub = DemandedBits.extractBits(NumSrcEltBits, Offset); - if (!Sub.isNullValue()) { - DemandedSrcBits |= Sub; - for (unsigned j = 0; j != NumElts; ++j) - if (DemandedElts[j]) - DemandedSrcElts.setBit((j * Scale) + i); - } - } - - if (SDValue V = SimplifyMultipleUseDemandedBits( - Src, DemandedSrcBits, DemandedSrcElts, DAG, Depth + 1)) - return DAG.getBitcast(DstVT, V); - } - - // TODO - bigendian once we have test coverage. - if ((NumSrcEltBits % NumDstEltBits) == 0 && - DAG.getDataLayout().isLittleEndian()) { - unsigned Scale = NumSrcEltBits / NumDstEltBits; - unsigned NumSrcElts = SrcVT.isVector() ? SrcVT.getVectorNumElements() : 1; - APInt DemandedSrcBits = APInt::getNullValue(NumSrcEltBits); - APInt DemandedSrcElts = APInt::getNullValue(NumSrcElts); - for (unsigned i = 0; i != NumElts; ++i) - if (DemandedElts[i]) { - unsigned Offset = (i % Scale) * NumDstEltBits; - DemandedSrcBits.insertBits(DemandedBits, Offset); - DemandedSrcElts.setBit(i / Scale); - } - - if (SDValue V = SimplifyMultipleUseDemandedBits( - Src, DemandedSrcBits, DemandedSrcElts, DAG, Depth + 1)) - return DAG.getBitcast(DstVT, V); - } - - break; - } case ISD::AND: { LHSKnown = DAG.computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); RHSKnown = DAG.computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); @@ -679,7 +622,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits( // If all the demanded elts are from one operand and are inline, // then we can use the operand directly. bool AllUndef = true, IdentityLHS = true, IdentityRHS = true; - for (unsigned i = 0; i != NumElts; ++i) { + for (unsigned i = 0, NumElts = ShuffleMask.size(); i != NumElts; ++i) { int M = ShuffleMask[i]; if (M < 0 || !DemandedElts[i]) continue; |