• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/llvm/lib/Analysis/

Lines Matching defs:Ops

809 static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
811 if (Ops.size() < 2) return; // Noop
815 if (Ops.size() == 2) {
818 const SCEV *&LHS = Ops[0], *&RHS = Ops[1];
825 llvm::stable_sort(Ops, [&](const SCEV *LHS, const SCEV *RHS) {
834 for (unsigned i = 0, e = Ops.size(); i != e-2; ++i) {
835 const SCEV *S = Ops[i];
840 for (unsigned j = i+1; j != e && Ops[j]->getSCEVType() == Complexity; ++j) {
841 if (Ops[j] == S) { // Found a duplicate.
843 std::swap(Ops[i+1], Ops[j]);
851 /// Returns true if \p Ops contains a huge SCEV (the subtree of S contains at
853 static bool hasHugeExpression(ArrayRef<const SCEV *> Ops) {
854 return any_of(Ops, [](const SCEV *S) {
1615 SmallVector<const SCEV *, 4> Ops;
1617 Ops.push_back(getZeroExtendExpr(Op, Ty, Depth + 1));
1618 return getAddExpr(Ops, SCEV::FlagNUW, Depth + 1);
1648 SmallVector<const SCEV *, 4> Ops;
1650 Ops.push_back(getZeroExtendExpr(Op, Ty, Depth + 1));
1651 return getMulExpr(Ops, SCEV::FlagNUW, Depth + 1);
1747 SmallVector<const SCEV *, 4> Ops;
1749 Ops.push_back(getSignExtendExpr(Op, Ty, Depth + 1));
1750 return getAddExpr(Ops, SCEV::FlagNSW, Depth + 1);
1978 SmallVector<const SCEV *, 4> Ops;
1980 Ops.push_back(getAnyExtendExpr(Op, Ty));
1981 return getAddRecExpr(Ops, AR->getLoop(), SCEV::FlagNW);
1992 /// Process the given Ops list, which is a list of operands to be added under
2019 const SCEV *const *Ops, size_t NumOperands,
2026 while (const SCEVConstant *C = dyn_cast<SCEVConstant>(Ops[i])) {
2037 const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[i]);
2066 M.insert({Ops[i], Scale});
2081 // We're trying to construct a SCEV of type `Type' with `Ops' as operands and
2086 const ArrayRef<const SCEV *> Ops,
2106 if (SignOrUnsignWrap == SCEV::FlagNSW && all_of(Ops, IsKnownNonNegative))
2113 (Type == scAddExpr || Type == scMulExpr) && Ops.size() == 2 &&
2114 isa<SCEVConstant>(Ops[0])) {
2127 const APInt &C = cast<SCEVConstant>(Ops[0])->getAPInt();
2133 if (NSWRegion.contains(SE->getSignedRange(Ops[1])))
2141 if (NUWRegion.contains(SE->getUnsignedRange(Ops[1])))
2154 const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
2159 assert(!Ops.empty() && "Cannot get empty add!");
2160 if (Ops.size() == 1) return Ops[0];
2162 Type *ETy = getEffectiveSCEVType(Ops[0]->getType());
2163 for (unsigned i = 1, e = Ops.size(); i != e; ++i)
2164 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy &&
2169 GroupByComplexity(Ops, &LI, DT);
2171 Flags = StrengthenNoWrapFlags(this, scAddExpr, Ops, Flags);
2175 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) {
2177 assert(Idx < Ops.size());
2178 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
2180 Ops[0] = getConstant(LHSC->getAPInt() + RHSC->getAPInt());
2181 if (Ops.size() == 2) return Ops[0];
2182 Ops.erase(Ops.begin()+1); // Erase the folded element
2183 LHSC = cast<SCEVConstant>(Ops[0]);
2188 Ops.erase(Ops.begin());
2192 if (Ops.size() == 1) return Ops[0];
2196 if (Depth > MaxArithDepth || hasHugeExpression(Ops))
2197 return getOrCreateAddExpr(Ops, Flags);
2199 if (SCEV *S = std::get<0>(findExistingSCEVInCache(scAddExpr, Ops))) {
2207 Type *Ty = Ops[0]->getType();
2209 for (unsigned i = 0, e = Ops.size(); i != e-1; ++i)
2210 if (Ops[i] == Ops[i+1]) { // X + Y + Y --> X + Y*2
2213 while (i+Count != e && Ops[i+Count] == Ops[i])
2217 const SCEV *Mul = getMulExpr(Scale, Ops[i], SCEV::FlagAnyWrap, Depth + 1);
2218 if (Ops.size() == Count)
2220 Ops[i] = Mul;
2221 Ops.erase(Ops.begin()+i+1, Ops.begin()+i+Count);
2226 return getAddExpr(Ops, Flags, Depth + 1);
2237 if (auto *T = dyn_cast<SCEVTruncateExpr>(Ops[Idx]))
2239 if (const auto *Mul = dyn_cast<SCEVMulExpr>(Ops[Idx])) {
2251 for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
2252 if (const SCEVTruncateExpr *T = dyn_cast<SCEVTruncateExpr>(Ops[i])) {
2258 } else if (const SCEVConstant *C = dyn_cast<SCEVConstant>(Ops[i])) {
2260 } else if (const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(Ops[i])) {
2294 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddExpr)
2298 if (Idx < Ops.size()) {
2300 while (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[Idx])) {
2301 if (Ops.size() > AddOpsInlineThreshold ||
2306 Ops.erase(Ops.begin()+Idx);
2307 Ops.append(Add->op_begin(), Add->op_end());
2315 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2319 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scMulExpr)
2324 if (Idx < Ops.size() && isa<SCEVMulExpr>(Ops[Idx])) {
2330 Ops.data(), Ops.size(),
2345 Ops.clear();
2347 Ops.push_back(getConstant(AccumulatedConstant));
2350 Ops.push_back(getMulExpr(
2354 if (Ops.empty())
2356 if (Ops.size() == 1)
2357 return Ops[0];
2358 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2365 for (; Idx < Ops.size() && isa<SCEVMulExpr>(Ops[Idx]); ++Idx) {
2366 const SCEVMulExpr *Mul = cast<SCEVMulExpr>(Ops[Idx]);
2371 for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp)
2372 if (MulOpSCEV == Ops[AddOp]) {
2387 if (Ops.size() == 2) return OuterMul;
2389 Ops.erase(Ops.begin()+AddOp);
2390 Ops.erase(Ops.begin()+Idx-1);
2392 Ops.erase(Ops.begin()+Idx);
2393 Ops.erase(Ops.begin()+AddOp-1);
2395 Ops.push_back(OuterMul);
2396 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2401 OtherMulIdx < Ops.size() && isa<SCEVMulExpr>(Ops[OtherMulIdx]);
2403 const SCEVMulExpr *OtherMul = cast<SCEVMulExpr>(Ops[OtherMulIdx]);
2429 if (Ops.size() == 2) return OuterMul;
2430 Ops.erase(Ops.begin()+Idx);
2431 Ops.erase(Ops.begin()+OtherMulIdx-1);
2432 Ops.push_back(OuterMul);
2433 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2442 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddRecExpr)
2446 for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
2450 const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
2452 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
2453 if (isAvailableAtLoopEntry(Ops[i], AddRecLoop)) {
2454 LIOps.push_back(Ops[i]);
2455 Ops.erase(Ops.begin()+i);
2478 if (Ops.size() == 1) return NewRec;
2482 if (Ops[i] == AddRec) {
2483 Ops[i] = NewRec;
2486 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2493 OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
2498 cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()->getHeader(),
2501 if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) {
2505 for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
2507 const auto *OtherAddRec = cast<SCEVAddRecExpr>(Ops[OtherIdx]);
2520 Ops.erase(Ops.begin() + OtherIdx); --OtherIdx;
2524 Ops[Idx] = getAddRecExpr(AddRecOps, AddRecLoop, SCEV::FlagAnyWrap);
2525 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2535 return getOrCreateAddExpr(Ops, Flags);
2539 ScalarEvolution::getOrCreateAddExpr(ArrayRef<const SCEV *> Ops,
2543 for (const SCEV *Op : Ops)
2549 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2550 std::uninitialized_copy(Ops.begin(), Ops.end(), O);
2552 SCEVAddExpr(ID.Intern(SCEVAllocator), O, Ops.size());
2561 ScalarEvolution::getOrCreateAddRecExpr(ArrayRef<const SCEV *> Ops,
2565 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
2566 ID.AddPointer(Ops[i]);
2572 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2573 std::uninitialized_copy(Ops.begin(), Ops.end(), O);
2575 SCEVAddRecExpr(ID.Intern(SCEVAllocator), O, Ops.size(), L);
2584 ScalarEvolution::getOrCreateMulExpr(ArrayRef<const SCEV *> Ops,
2588 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
2589 ID.AddPointer(Ops[i]);
2594 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2595 std::uninitialized_copy(Ops.begin(), Ops.end(), O);
2597 O, Ops.size());
2660 const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
2665 assert(!Ops.empty() && "Cannot get empty mul!");
2666 if (Ops.size() == 1) return Ops[0];
2668 Type *ETy = getEffectiveSCEVType(Ops[0]->getType());
2669 for (unsigned i = 1, e = Ops.size(); i != e; ++i)
2670 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy &&
2675 GroupByComplexity(Ops, &LI, DT);
2677 Flags = StrengthenNoWrapFlags(this, scMulExpr, Ops, Flags);
2680 // `Ops` is sorted, so it's enough to check just last one.
2681 if ((Depth > MaxArithDepth || hasHugeExpression(Ops)) &&
2682 !isa<SCEVConstant>(Ops.back()))
2683 return getOrCreateMulExpr(Ops, Flags);
2685 if (SCEV *S = std::get<0>(findExistingSCEVInCache(scMulExpr, Ops))) {
2692 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) {
2694 if (Ops.size() == 2)
2696 if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[1]))
2711 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
2715 Ops[0] = getConstant(Fold);
2716 Ops.erase(Ops.begin()+1); // Erase the folded element
2717 if (Ops.size() == 1) return Ops[0];
2718 LHSC = cast<SCEVConstant>(Ops[0]);
2722 if (cast<SCEVConstant>(Ops[0])->getValue()->isOne()) {
2723 Ops.erase(Ops.begin());
2725 } else if (cast<SCEVConstant>(Ops[0])->getValue()->isZero()) {
2727 return Ops[0];
2728 } else if (Ops[0]->isAllOnesValue()) {
2731 if (Ops.size() == 2) {
2732 if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[1])) {
2736 const SCEV *Mul = getMulExpr(Ops[0], AddOp, SCEV::FlagAnyWrap,
2743 } else if (const auto *AddRec = dyn_cast<SCEVAddRecExpr>(Ops[1])) {
2747 Operands.push_back(getMulExpr(Ops[0], AddRecOp, SCEV::FlagAnyWrap,
2756 if (Ops.size() == 1)
2757 return Ops[0];
2761 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scMulExpr)
2765 if (Idx < Ops.size()) {
2767 while (const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Ops[Idx])) {
2768 if (Ops.size() > MulOpsInlineThreshold)
2772 Ops.erase(Ops.begin()+Idx);
2773 Ops.append(Mul->op_begin(), Mul->op_end());
2781 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2787 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < scAddRecExpr)
2791 for (; Idx < Ops.size() && isa<SCEVAddRecExpr>(Ops[Idx]); ++Idx) {
2795 const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]);
2797 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
2798 if (isAvailableAtLoopEntry(Ops[i], AddRecLoop)) {
2799 LIOps.push_back(Ops[i]);
2800 Ops.erase(Ops.begin()+i);
2823 if (Ops.size() == 1) return NewRec;
2827 if (Ops[i] == AddRec) {
2828 Ops[i] = NewRec;
2831 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2850 OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
2853 dyn_cast<SCEVAddRecExpr>(Ops[OtherIdx]);
2895 if (Ops.size() == 2) return NewAddRec;
2896 Ops[Idx] = NewAddRec;
2897 Ops.erase(Ops.begin() + OtherIdx); --OtherIdx;
2905 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2913 return getOrCreateMulExpr(Ops, Flags);
3325 ArrayRef<const SCEV *> Ops) {
3329 for (unsigned i = 0, e = Ops.size(); i != e; ++i)
3330 ID.AddPointer(Ops[i]);
3336 SmallVectorImpl<const SCEV *> &Ops) {
3337 assert(!Ops.empty() && "Cannot get empty (u|s)(min|max)!");
3338 if (Ops.size() == 1) return Ops[0];
3340 Type *ETy = getEffectiveSCEVType(Ops[0]->getType());
3341 for (unsigned i = 1, e = Ops.size(); i != e; ++i)
3342 assert(getEffectiveSCEVType(Ops[i]->getType()) == ETy &&
3350 GroupByComplexity(Ops, &LI, DT);
3353 if (const SCEV *S = std::get<0>(findExistingSCEVInCache(Kind, Ops))) {
3359 if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) {
3361 assert(Idx < Ops.size());
3374 while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
3378 Ops[0] = getConstant(Fold);
3379 Ops.erase(Ops.begin()+1); // Erase the folded element
3380 if (Ops.size() == 1) return Ops[0];
3381 LHSC = cast<SCEVConstant>(Ops[0]);
3389 Ops.erase(Ops.begin());
3397 if (Ops.size() == 1) return Ops[0];
3401 while (Idx < Ops.size() && Ops[Idx]->getSCEVType() < Kind)
3406 if (Idx < Ops.size()) {
3408 while (Ops[Idx]->getSCEVType() == Kind) {
3409 const SCEVMinMaxExpr *SMME = cast<SCEVMinMaxExpr>(Ops[Idx]);
3410 Ops.erase(Ops.begin()+Idx);
3411 Ops.append(SMME->op_begin(), SMME->op_end());
3416 return getMinMaxExpr(Kind, Ops);
3428 for (unsigned i = 0, e = Ops.size() - 1; i != e; ++i) {
3429 if (Ops[i] == Ops[i + 1] ||
3430 isKnownViaNonRecursiveReasoning(FirstPred, Ops[i], Ops[i + 1])) {
3433 Ops.erase(Ops.begin() + i + 1, Ops.begin() + i + 2);
3436 } else if (isKnownViaNonRecursiveReasoning(SecondPred, Ops[i],
3437 Ops[i + 1])) {
3439 Ops.erase(Ops.begin() + i, Ops.begin() + i + 1);
3445 if (Ops.size() == 1) return Ops[0];
3447 assert(!Ops.empty() && "Reduced smax down to nothing!");
3454 std::tie(ExistingSCEV, ID, IP) = findExistingSCEVInCache(Kind, Ops);
3457 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
3458 std::uninitialized_copy(Ops.begin(), Ops.end(), O);
3460 ID.Intern(SCEVAllocator), static_cast<SCEVTypes>(Kind), O, Ops.size());
3468 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
3469 return getSMaxExpr(Ops);
3472 const SCEV *ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3473 return getMinMaxExpr(scSMaxExpr, Ops);
3477 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
3478 return getUMaxExpr(Ops);
3481 const SCEV *ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3482 return getMinMaxExpr(scUMaxExpr, Ops);
3487 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
3488 return getSMinExpr(Ops);
3491 const SCEV *ScalarEvolution::getSMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3492 return getMinMaxExpr(scSMinExpr, Ops);
3497 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
3498 return getUMinExpr(Ops);
3501 const SCEV *ScalarEvolution::getUMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3502 return getMinMaxExpr(scUMinExpr, Ops);
3923 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
3924 return getUMinFromMismatchedTypes(Ops);
3928 SmallVectorImpl<const SCEV *> &Ops) {
3929 assert(!Ops.empty() && "At least one operand must be!");
3931 if (Ops.size() == 1)
3932 return Ops[0];
3936 for (auto *S : Ops)
3944 for (auto *S : Ops)
4544 SmallVector<const SCEV *, 8> Ops;
4547 Ops.push_back(Add->getOperand(i));
4548 const SCEV *Accum = getAddExpr(Ops);
4866 SmallVector<const SCEV *, 8> Ops;
4869 Ops.push_back(SCEVBackedgeConditionFolder::rewrite(Add->getOperand(i),
4871 const SCEV *Accum = getAddExpr(Ops);
6750 SmallVector<const SCEV *, 2> Ops;
6758 Ops.push_back(BECount);
6767 return SE->getUMinFromMismatchedTypes(Ops);
10744 SmallVector<const SCEV *, 3> Ops;
10748 Ops.push_back(SE.getAddExpr(getOperand(i), getOperand(i + 1)));
10755 Ops.push_back(Last);
10756 return cast<SCEVAddRecExpr>(SE.getAddRecExpr(Ops, getLoop(),