Lines Matching defs:LU
780 static bool isLegal2RegAMUse(const TargetTransformInfo &TTI, const LSRUse &LU,
782 // Get the cost of the scaling factor used in F for LU.
784 const LSRUse &LU, const Formula &F);
831 const LSRUse &LU,
923 const LSRUse &LU,
952 NumBaseAdds += NumBaseParts - (1 + isLegal2RegAMUse(TTI, LU, F));
955 ScaleCost += getScalingFactorCost(TTI, LU, F);
1387 static bool isLegal2RegAMUse(const TargetTransformInfo &TTI, const LSRUse &LU,
1396 if (LU.Kind != LSRUse::Address)
1407 return isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,
1412 const LSRUse &LU, const Formula &F) {
1415 assert(isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind,
1416 LU.AccessTy, F) && "Illegal formula in use.");
1418 switch (LU.Kind) {
1422 TTI.getScalingFactorCost(LU.AccessTy, F.BaseGV,
1423 F.BaseOffset + LU.MinOffset,
1426 TTI.getScalingFactorCost(LU.AccessTy, F.BaseGV,
1427 F.BaseOffset + LU.MaxOffset,
1653 bool reconcileNewOffset(LSRUse &LU, int64_t NewOffset, bool HasBaseReg,
1660 void DeleteUse(LSRUse &LU, size_t LUIdx);
1664 void InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
1665 void InsertSupplementalFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
1667 bool InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F);
1671 void GenerateReassociations(LSRUse &LU, unsigned LUIdx, Formula Base,
1673 void GenerateCombinations(LSRUse &LU, unsigned LUIdx, Formula Base);
1674 void GenerateSymbolicOffsets(LSRUse &LU, unsigned LUIdx, Formula Base);
1675 void GenerateConstantOffsets(LSRUse &LU, unsigned LUIdx, Formula Base);
1676 void GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx, Formula Base);
1677 void GenerateScales(LSRUse &LU, unsigned LUIdx, Formula Base);
1678 void GenerateTruncates(LSRUse &LU, unsigned LUIdx, Formula Base);
1705 const LSRUse &LU,
2166 LSRInstance::reconcileNewOffset(LSRUse &LU, int64_t NewOffset, bool HasBaseReg,
2168 int64_t NewMinOffset = LU.MinOffset;
2169 int64_t NewMaxOffset = LU.MaxOffset;
2175 if (LU.Kind != Kind)
2178 if (NewOffset < LU.MinOffset) {
2180 LU.MaxOffset - NewOffset, HasBaseReg))
2183 } else if (NewOffset > LU.MaxOffset) {
2185 NewOffset - LU.MinOffset, HasBaseReg))
2192 if (Kind == LSRUse::Address && AccessTy != LU.AccessTy)
2196 LU.MinOffset = NewMinOffset;
2197 LU.MaxOffset = NewMaxOffset;
2198 LU.AccessTy = NewAccessTy;
2199 if (NewOffset != LU.Offsets.back())
2200 LU.Offsets.push_back(NewOffset);
2225 LSRUse &LU = Uses[LUIdx];
2226 if (reconcileNewOffset(LU, Offset, /*HasBaseReg=*/true, Kind, AccessTy))
2235 LSRUse &LU = Uses[LUIdx];
2239 if (LU.Offsets.empty() || Offset != LU.Offsets.back())
2240 LU.Offsets.push_back(Offset);
2242 LU.MinOffset = Offset;
2243 LU.MaxOffset = Offset;
2248 void LSRInstance::DeleteUse(LSRUse &LU, size_t LUIdx) {
2249 if (&LU != &Uses.back())
2250 std::swap(LU, Uses.back());
2264 LSRUse &LU = Uses[LUIdx];
2270 if (&LU != &OrigLU &&
2271 LU.Kind != LSRUse::ICmpZero &&
2272 LU.Kind == OrigLU.Kind && OrigLU.AccessTy == LU.AccessTy &&
2273 LU.WidestFixupType == OrigLU.WidestFixupType &&
2274 LU.HasFormulaWithSameRegs(OrigF)) {
2276 for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
2277 E = LU.Formulae.end(); I != E; ++I) {
2287 return &LU;
2967 LSRUse &LU = Uses[LF.LUIdx];
2968 LU.AllFixupsOutsideLoop &= LF.isUseFullyOutsideLoop(L);
2969 if (!LU.WidestFixupType ||
2970 SE.getTypeSizeInBits(LU.WidestFixupType) <
2972 LU.WidestFixupType = LF.OperandValToReplace->getType();
2975 if (LU.Formulae.empty()) {
2976 InsertInitialFormula(S, LU, LF.LUIdx);
2977 CountRegisters(LU.Formulae.back(), LF.LUIdx);
2988 LSRInstance::InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx) {
2991 bool Inserted = InsertFormula(LU, LUIdx, F);
2999 LSRUse &LU, size_t LUIdx) {
3003 bool Inserted = InsertFormula(LU, LUIdx, F);
3019 bool LSRInstance::InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F) {
3020 if (!LU.InsertFormula(F))
3100 LSRUse &LU = Uses[LF.LUIdx];
3101 LU.AllFixupsOutsideLoop &= LF.isUseFullyOutsideLoop(L);
3102 if (!LU.WidestFixupType ||
3103 SE.getTypeSizeInBits(LU.WidestFixupType) <
3105 LU.WidestFixupType = LF.OperandValToReplace->getType();
3106 InsertSupplementalFormula(U, LU, LF.LUIdx);
3107 CountRegisters(LU.Formulae.back(), Uses.size() - 1);
3178 void LSRInstance::GenerateReassociations(LSRUse &LU, unsigned LUIdx,
3204 if (isAlwaysFoldable(TTI, SE, LU.MinOffset, LU.MaxOffset, LU.Kind,
3205 LU.AccessTy, *J, Base.getNumRegs() > 1))
3217 isAlwaysFoldable(TTI, SE, LU.MinOffset, LU.MaxOffset, LU.Kind,
3218 LU.AccessTy, InnerAddOps[0], Base.getNumRegs() > 1))
3248 if (InsertFormula(LU, LUIdx, F))
3251 GenerateReassociations(LU, LUIdx, LU.Formulae.back(), Depth+1);
3258 void LSRInstance::GenerateCombinations(LSRUse &LU, unsigned LUIdx,
3282 (void)InsertFormula(LU, LUIdx, F);
3288 void LSRInstance::GenerateSymbolicOffsets(LSRUse &LU, unsigned LUIdx,
3300 if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, F))
3303 (void)InsertFormula(LU, LUIdx, F);
3308 void LSRInstance::GenerateConstantOffsets(LSRUse &LU, unsigned LUIdx,
3313 Worklist.push_back(LU.MinOffset);
3314 if (LU.MaxOffset != LU.MinOffset)
3315 Worklist.push_back(LU.MaxOffset);
3324 if (isLegalUse(TTI, LU.MinOffset - *I, LU.MaxOffset - *I, LU.Kind,
3325 LU.AccessTy, F)) {
3335 (void)InsertFormula(LU, LUIdx, F);
3344 if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, F))
3347 (void)InsertFormula(LU, LUIdx, F);
3353 void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
3355 if (LU.Kind != LSRUse::ICmpZero) return;
3363 if (LU.MinOffset != LU.MaxOffset) return;
3380 int64_t Offset = LU.MinOffset;
3384 if (Offset / Factor != LU.MinOffset)
3391 if (!isLegalUse(TTI, Offset, Offset, LU.Kind, LU.AccessTy, F))
3395 F.BaseOffset = (uint64_t)F.BaseOffset + Offset - LU.MinOffset;
3423 (void)InsertFormula(LU, LUIdx, F);
3430 void LSRInstance::GenerateScales(LSRUse &LU, unsigned LUIdx, Formula Base) {
3446 if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,
3450 if (LU.Kind == LSRUse::Basic &&
3451 isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LSRUse::Special,
3452 LU.AccessTy, Base) &&
3453 LU.AllFixupsOutsideLoop)
3454 LU.Kind = LSRUse::Special;
3460 if (LU.Kind == LSRUse::ICmpZero &&
3477 (void)InsertFormula(LU, LUIdx, F);
3484 void LSRInstance::GenerateTruncates(LSRUse &LU, unsigned LUIdx, Formula Base) {
3509 (void)InsertFormula(LU, LUIdx, F);
3630 LSRUse &LU = Uses[LUIdx];
3639 for (size_t L = 0, LE = LU.Formulae.size(); L != LE; ++L) {
3640 const Formula &F = LU.Formulae[L];
3650 if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,
3666 (void)InsertFormula(LU, LUIdx, NewF);
3675 if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset,
3676 LU.Kind, LU.AccessTy, NewF)) {
3699 (void)InsertFormula(LU, LUIdx, NewF);
3714 LSRUse &LU = Uses[LUIdx];
3715 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3716 GenerateReassociations(LU, LUIdx, LU.Formulae[i]);
3717 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3718 GenerateCombinations(LU, LUIdx, LU.Formulae[i]);
3721 LSRUse &LU = Uses[LUIdx];
3722 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3723 GenerateSymbolicOffsets(LU, LUIdx, LU.Formulae[i]);
3724 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3725 GenerateConstantOffsets(LU, LUIdx, LU.Formulae[i]);
3726 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3727 GenerateICmpZeroScales(LU, LUIdx, LU.Formulae[i]);
3728 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3729 GenerateScales(LU, LUIdx, LU.Formulae[i]);
3732 LSRUse &LU = Uses[LUIdx];
3733 for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i)
3734 GenerateTruncates(LU, LUIdx, LU.Formulae[i]);
3761 LSRUse &LU = Uses[LUIdx];
3762 DEBUG(dbgs() << "Filtering for use "; LU.print(dbgs()); dbgs() << '\n');
3765 for (size_t FIdx = 0, NumForms = LU.Formulae.size();
3767 Formula &F = LU.Formulae[FIdx];
3778 CostF.RateFormula(TTI, F, Regs, VisitedRegs, L, LU.Offsets, SE, DT, LU,
3810 Formula &Best = LU.Formulae[P.first->second];
3814 CostBest.RateFormula(TTI, Best, Regs, VisitedRegs, L, LU.Offsets, SE,
3815 DT, LU);
3826 LU.DeleteFormula(F);
3834 LU.RecomputeRegs(LUIdx, RegUses);
3883 LSRUse &LU = Uses[LUIdx];
3885 for (size_t i = 0, e = LU.Formulae.size(); i != e; ++i) {
3886 Formula &F = LU.Formulae[i];
3897 if (LU.HasFormulaWithSameRegs(NewF)) {
3899 LU.DeleteFormula(F);
3912 if (LU.HasFormulaWithSameRegs(NewF)) {
3915 LU.DeleteFormula(F);
3926 LU.RecomputeRegs(LUIdx, RegUses);
3948 LSRUse &LU = Uses[LUIdx];
3949 for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
3950 E = LU.Formulae.end(); I != E; ++I) {
3955 LSRUse *LUThatHas = FindUseWithSimilarFormula(F, LU);
3960 LU.Kind, LU.AccessTy))
3963 DEBUG(dbgs() << " Deleting use "; LU.print(dbgs()); dbgs() << '\n');
3965 LUThatHas->AllFixupsOutsideLoop &= LU.AllFixupsOutsideLoop;
4007 DeleteUse(LU, LUIdx);
4074 LSRUse &LU = Uses[LUIdx];
4075 if (!LU.Regs.count(Best)) continue;
4078 for (size_t i = 0, e = LU.Formulae.size(); i != e; ++i) {
4079 Formula &F = LU.Formulae[i];
4082 LU.DeleteFormula(F);
4092 LU.RecomputeRegs(LUIdx, RegUses);
4128 const LSRUse &LU = Uses[Workspace.size()];
4137 if (LU.Regs.count(*I))
4142 for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
4143 E = LU.Formulae.end(); I != E; ++I) {
4168 NewCost.RateFormula(TTI, F, NewRegs, VisitedRegs, L, LU.Offsets, SE, DT,
4169 LU);
4287 const LSRUse &LU,
4295 if (LU.Kind == LSRUse::ICmpZero)
4355 const LSRUse &LU = Uses[LF.LUIdx];
4359 LU, Rewriter);
4407 if (LU.Kind == LSRUse::ICmpZero) {
4419 if (!Ops.empty() && LU.Kind == LSRUse::Address) {
4453 if (LU.Kind == LSRUse::ICmpZero) {
4489 if (LU.Kind == LSRUse::ICmpZero) {
4768 const LSRUse &LU = *I;
4769 for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(),
4770 JE = LU.Formulae.end();
4772 assert(isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,
4817 const LSRUse &LU = *I;
4819 LU.print(OS);
4821 for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(),
4822 JE = LU.Formulae.end(); J != JE; ++J) {