[DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC
This commit is contained in:
parent
1f5fdc22a2
commit
7aa7393aab
|
@ -559,11 +559,12 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
|
|||
assert(Op.getNode()->getNumValues() == 1 &&
|
||||
"ShrinkDemandedOp only supports nodes with one result!");
|
||||
|
||||
EVT VT = Op.getValueType();
|
||||
SelectionDAG &DAG = TLO.DAG;
|
||||
SDLoc dl(Op);
|
||||
|
||||
// Early return, as this function cannot handle vector types.
|
||||
if (Op.getValueType().isVector())
|
||||
if (VT.isVector())
|
||||
return false;
|
||||
|
||||
// Don't do this if the node has another user, which may require the
|
||||
|
@ -579,15 +580,14 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned BitWidth,
|
|||
SmallVTBits = llvm::bit_ceil(SmallVTBits);
|
||||
for (; SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2(SmallVTBits)) {
|
||||
EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), SmallVTBits);
|
||||
if (TLI.isTruncateFree(Op.getValueType(), SmallVT) &&
|
||||
TLI.isZExtFree(SmallVT, Op.getValueType())) {
|
||||
if (TLI.isTruncateFree(VT, SmallVT) && TLI.isZExtFree(SmallVT, VT)) {
|
||||
// We found a type with free casts.
|
||||
SDValue X = DAG.getNode(
|
||||
Op.getOpcode(), dl, SmallVT,
|
||||
DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(0)),
|
||||
DAG.getNode(ISD::TRUNCATE, dl, SmallVT, Op.getOperand(1)));
|
||||
assert(DemandedSize <= SmallVTBits && "Narrowed below demanded bits?");
|
||||
SDValue Z = DAG.getNode(ISD::ANY_EXTEND, dl, Op.getValueType(), X);
|
||||
SDValue Z = DAG.getNode(ISD::ANY_EXTEND, dl, VT, X);
|
||||
return TLO.CombineTo(Op, Z);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user