@@ -1402,8 +1402,7 @@ void Cost::RateRegister(const Formula &F, const SCEV *Reg,
14021402 // for now LSR only handles innermost loops).
14031403 if (AR->getLoop () != L) {
14041404 // If the AddRec exists, consider it's register free and leave it alone.
1405- if (isExistingPhi (AR, *SE) && AMK != TTI::AMK_PostIndexed &&
1406- AMK != TTI::AMK_All)
1405+ if (isExistingPhi (AR, *SE) && !(AMK & TTI::AMK_PostIndexed))
14071406 return ;
14081407
14091408 // It is bad to allow LSR for current loop to add induction variables
@@ -1426,11 +1425,10 @@ void Cost::RateRegister(const Formula &F, const SCEV *Reg,
14261425 if (match (AR, m_scev_AffineAddRec (m_SCEV (Start), m_SCEVConstant (Step))))
14271426 // If the step size matches the base offset, we could use pre-indexed
14281427 // addressing.
1429- if (((AMK == TTI::AMK_PreIndexed || AMK == TTI::AMK_All) &&
1430- F.BaseOffset .isFixed () &&
1428+ if (((AMK & TTI::AMK_PreIndexed) && F.BaseOffset .isFixed () &&
14311429 Step->getAPInt () == F.BaseOffset .getFixedValue ()) ||
1432- ((AMK == TTI::AMK_PostIndexed || AMK == TTI::AMK_All ) &&
1433- !isa<SCEVConstant>(Start) && SE->isLoopInvariant (Start, L)))
1430+ ((AMK & TTI::AMK_PostIndexed) && !isa<SCEVConstant>(Start ) &&
1431+ SE->isLoopInvariant (Start, L)))
14341432 LoopCost = 0 ;
14351433 }
14361434 // If the loop counts down to zero and we'll be using a hardware loop then
@@ -4147,8 +4145,7 @@ void LSRInstance::GenerateConstantOffsetsImpl(
41474145 // means that a single pre-indexed access can be generated to become the new
41484146 // base pointer for each iteration of the loop, resulting in no extra add/sub
41494147 // instructions for pointer updating.
4150- if ((AMK == TTI::AMK_PreIndexed || AMK == TTI::AMK_All) &&
4151- LU.Kind == LSRUse::Address) {
4148+ if ((AMK & TTI::AMK_PreIndexed) && LU.Kind == LSRUse::Address) {
41524149 const APInt *StepInt;
41534150 if (match (G, m_scev_AffineAddRec (m_SCEV (), m_scev_APInt (StepInt)))) {
41544151 int64_t Step = StepInt->isNegative () ? StepInt->getSExtValue ()
@@ -5438,8 +5435,7 @@ void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution,
54385435 // This can sometimes (notably when trying to favour postinc) lead to
54395436 // sub-optimial decisions. There it is best left to the cost modelling to
54405437 // get correct.
5441- if ((AMK != TTI::AMK_PostIndexed && AMK != TTI::AMK_All) ||
5442- LU.Kind != LSRUse::Address) {
5438+ if (!(AMK & TTI::AMK_PostIndexed) || LU.Kind != LSRUse::Address) {
54435439 int NumReqRegsToFind = std::min (F.getNumRegs (), ReqRegs.size ());
54445440 for (const SCEV *Reg : ReqRegs) {
54455441 if ((F.ScaledReg && F.ScaledReg == Reg) ||
0 commit comments