[SCEVPatternMatch] Add signed cst match; use in LV (NFC) (#154568)
Add a m_scev_SpecificSInt for matching a sign-extended value, and use it to improve some code in LoopVectorize.
This commit is contained in:
parent
5c36fb3303
commit
a96b78cf41
@ -116,6 +116,18 @@ struct is_specific_cst {
|
|||||||
/// Match an SCEV constant with a plain unsigned integer.
|
/// Match an SCEV constant with a plain unsigned integer.
|
||||||
inline cst_pred_ty<is_specific_cst> m_scev_SpecificInt(uint64_t V) { return V; }
|
inline cst_pred_ty<is_specific_cst> m_scev_SpecificInt(uint64_t V) { return V; }
|
||||||
|
|
||||||
|
struct is_specific_signed_cst {
|
||||||
|
int64_t CV;
|
||||||
|
is_specific_signed_cst(int64_t C) : CV(C) {}
|
||||||
|
bool isValue(const APInt &C) const { return C.trySExtValue() == CV; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Match an SCEV constant with a plain signed integer (sign-extended value will
|
||||||
|
/// be matched)
|
||||||
|
inline cst_pred_ty<is_specific_signed_cst> m_scev_SpecificSInt(int64_t V) {
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
struct bind_cst_ty {
|
struct bind_cst_ty {
|
||||||
const APInt *&CR;
|
const APInt *&CR;
|
||||||
|
|
||||||
|
@ -5918,23 +5918,13 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
|
|||||||
// TODO: do we need to figure out the cost of an extract to get the
|
// TODO: do we need to figure out the cost of an extract to get the
|
||||||
// first lane? Or do we hope that it will be folded away?
|
// first lane? Or do we hope that it will be folded away?
|
||||||
ScalarEvolution *SE = PSE.getSE();
|
ScalarEvolution *SE = PSE.getSE();
|
||||||
const auto *SAR =
|
if (!match(SE->getSCEV(ScalarParam),
|
||||||
dyn_cast<SCEVAddRecExpr>(SE->getSCEV(ScalarParam));
|
m_scev_AffineAddRec(
|
||||||
|
m_SCEV(), m_scev_SpecificSInt(Param.LinearStepOrPos),
|
||||||
if (!SAR || SAR->getLoop() != TheLoop) {
|
m_SpecificLoop(TheLoop))))
|
||||||
ParamsOk = false;
|
ParamsOk = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCEVConstant *Step =
|
|
||||||
dyn_cast<SCEVConstant>(SAR->getStepRecurrence(*SE));
|
|
||||||
|
|
||||||
if (!Step ||
|
|
||||||
Step->getAPInt().getSExtValue() != Param.LinearStepOrPos)
|
|
||||||
ParamsOk = false;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case VFParamKind::GlobalPredicate:
|
case VFParamKind::GlobalPredicate:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user