forked from OSchip/llvm-project
[X86] detectAVGPattern - use matchUnaryPredicate helper. NFC.
Use the ISD::matchUnaryPredicate helper to check for inrange constants.
This commit is contained in:
parent
7cf0f8568c
commit
4d2b0ebd17
|
@ -42492,18 +42492,9 @@ static SDValue detectAVGPattern(SDValue In, EVT VT, SelectionDAG &DAG,
|
|||
// A lambda checking the given SDValue is a constant vector and each element
|
||||
// is in the range [Min, Max].
|
||||
auto IsConstVectorInRange = [](SDValue V, unsigned Min, unsigned Max) {
|
||||
BuildVectorSDNode *BV = dyn_cast<BuildVectorSDNode>(V);
|
||||
if (!BV || !BV->isConstant())
|
||||
return false;
|
||||
for (SDValue Op : V->ops()) {
|
||||
ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op);
|
||||
if (!C)
|
||||
return false;
|
||||
const APInt &Val = C->getAPIntValue();
|
||||
if (Val.ult(Min) || Val.ugt(Max))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return ISD::matchUnaryPredicate(V, [Min, Max](ConstantSDNode *C) {
|
||||
return !(C->getAPIntValue().ult(Min) || C->getAPIntValue().ugt(Max));
|
||||
});
|
||||
};
|
||||
|
||||
// Check if each element of the vector is right-shifted by one.
|
||||
|
|
Loading…
Reference in New Issue