Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 9,238 Lines • ▼ Show 20 Lines | static SDValue combineShiftToMULH(SDNode *N, SelectionDAG &DAG, | ||||
bool IsZeroExt = LeftOp.getOpcode() == ISD::ZERO_EXTEND; | bool IsZeroExt = LeftOp.getOpcode() == ISD::ZERO_EXTEND; | ||||
if (!IsSignExt && !IsZeroExt) | if (!IsSignExt && !IsZeroExt) | ||||
return SDValue(); | return SDValue(); | ||||
EVT NarrowVT = LeftOp.getOperand(0).getValueType(); | EVT NarrowVT = LeftOp.getOperand(0).getValueType(); | ||||
unsigned NarrowVTSize = NarrowVT.getScalarSizeInBits(); | unsigned NarrowVTSize = NarrowVT.getScalarSizeInBits(); | ||||
// return true if U may use the lower bits of its operands | |||||
auto UserOfLowerBits = [NarrowVTSize](SDNode *U) { | |||||
if (U->getOpcode() != ISD::SRL || U->getOpcode() != ISD::SRA) { | |||||
RKSimon: @jmmartinez I'm getting static analysis warnings that this is always true - should this be:
```… | |||||
jmmartinezAuthorUnsubmitted Well spotted! I'll submit a fix for it. BTW what are you using for static analysis? jmmartinez: Well spotted! I'll submit a fix for it. BTW what are you using for static analysis? | |||||
RKSimonUnsubmitted Not Done ReplyInline ActionsCheers - VisualAssist 'code inspection' caught this one RKSimon: Cheers - VisualAssist 'code inspection' caught this one | |||||
RKSimonUnsubmitted Not Done ReplyInline ActionsSorry, amazingly its Intellisense that caught it - they get listed in the same window RKSimon: Sorry, amazingly its Intellisense that caught it - they get listed in the same window | |||||
return true; | |||||
} | |||||
ConstantSDNode *UShiftAmtSrc = isConstOrConstSplat(U->getOperand(1)); | |||||
if (!UShiftAmtSrc) { | |||||
return true; | |||||
} | |||||
unsigned UShiftAmt = UShiftAmtSrc->getZExtValue(); | |||||
return UShiftAmt < NarrowVTSize; | |||||
}; | |||||
// If the lower part of the MUL is also used and MUL_LOHI is supported | |||||
// do not introduce the MULH in favor of MUL_LOHI | |||||
unsigned MulLoHiOp = IsSignExt ? ISD::SMUL_LOHI : ISD::UMUL_LOHI; | |||||
if (!ShiftOperand.hasOneUse() && | |||||
Probably should use !hasOneUse instead of computing use_size arsenm: Probably should use !hasOneUse instead of computing use_size | |||||
TLI.isOperationLegalOrCustom(MulLoHiOp, NarrowVT) && | |||||
llvm::any_of(ShiftOperand->uses(), UserOfLowerBits)) { | |||||
return SDValue(); | |||||
} | |||||
SDValue MulhRightOp; | SDValue MulhRightOp; | ||||
if (ConstantSDNode *Constant = isConstOrConstSplat(RightOp)) { | if (ConstantSDNode *Constant = isConstOrConstSplat(RightOp)) { | ||||
unsigned ActiveBits = IsSignExt | unsigned ActiveBits = IsSignExt | ||||
? Constant->getAPIntValue().getMinSignedBits() | ? Constant->getAPIntValue().getMinSignedBits() | ||||
: Constant->getAPIntValue().getActiveBits(); | : Constant->getAPIntValue().getActiveBits(); | ||||
if (ActiveBits > NarrowVTSize) | if (ActiveBits > NarrowVTSize) | ||||
return SDValue(); | return SDValue(); | ||||
MulhRightOp = DAG.getConstant( | MulhRightOp = DAG.getConstant( | ||||
▲ Show 20 Lines • Show All 15,925 Lines • Show Last 20 Lines |
@jmmartinez I'm getting static analysis warnings that this is always true - should this be: