54#define DEBUG_TYPE "loop-utils"
69 "Must start with an empty predecessors list!");
74 bool IsDedicatedExit =
true;
76 if (L->contains(PredBB)) {
83 IsDedicatedExit =
false;
86 assert(!InLoopPredecessors.
empty() &&
"Must have *some* loop predecessor!");
93 BB, InLoopPredecessors,
".loopexit", DT, LI, MSSAU, PreserveLCSSA);
97 dbgs() <<
"WARNING: Can't create a dedicated exit block for loop: "
100 LLVM_DEBUG(
dbgs() <<
"LoopSimplify: Creating dedicated exit block "
101 << NewExitBB->getName() <<
"\n");
108 for (
auto *BB : L->blocks())
111 if (L->contains(SuccBB))
115 if (!Visited.
insert(SuccBB).second)
118 Changed |= RewriteExit(SuccBB);
128 for (
auto *
Block : L->getBlocks())
131 for (
auto &Inst : *
Block) {
132 auto Users = Inst.users();
135 return !L->contains(
Use->getParent());
222 for (
unsigned i = 1, ie = LoopID->
getNumOperands(); i < ie; ++i) {
225 if (
Node->getNumOperands() == 2) {
258 if (
Node->getNumOperands() == 1)
260 if (S->getString() == StringMD)
271std::optional<ElementCount>
273 std::optional<int> Width =
289 const char *InheritOptionsExceptPrefix,
bool AlwaysNew) {
298 bool InheritAllAttrs = !InheritOptionsExceptPrefix;
299 bool InheritSomeAttrs =
300 InheritOptionsExceptPrefix && InheritOptionsExceptPrefix[0] !=
'\0';
305 if (InheritAllAttrs || InheritSomeAttrs) {
309 auto InheritThisAttribute = [InheritSomeAttrs,
310 InheritOptionsExceptPrefix](
MDNode *
Op) {
311 if (!InheritSomeAttrs)
315 if (
Op->getNumOperands() == 0)
323 return !AttrName.
starts_with(InheritOptionsExceptPrefix);
326 if (InheritThisAttribute(
Op))
336 bool HasAnyFollowup =
false;
337 for (
StringRef OptionName : FollowupOptions) {
342 HasAnyFollowup =
true;
351 if (!AlwaysNew && !HasAnyFollowup)
365 return FollowupLoopID;
379 if (IsVectorBody && IsEpilogue)
380 return "vectorized epilogue ";
382 return "vectorized ";
392 std::optional<int>
Count =
413 std::optional<int>
Count =
433 std::optional<ElementCount> VectorizeWidth =
435 std::optional<int> InterleaveCount =
440 if (
Enable && VectorizeWidth && VectorizeWidth->isScalar() &&
441 InterleaveCount == 1)
450 if ((VectorizeWidth && VectorizeWidth->isScalar()) && InterleaveCount == 1)
453 if ((VectorizeWidth && VectorizeWidth->isVector()) || InterleaveCount > 1)
489 const Loop *CurLoop) {
498 AddRegionToWorklist(
N);
500 for (
size_t I = 0;
I < Worklist.
size();
I++) {
502 AddRegionToWorklist(Child);
510 assert(LatchIdx != -1 &&
"LatchBlock is not a case in this PHINode");
514 if (U !=
Cond && U != IncV)
return false;
517 if (U !=
Cond && U != PN)
return false;
524 assert((!DT || L->isLCSSAForm(*DT)) &&
"Expected LCSSA!");
525 auto *Preheader = L->getLoopPreheader();
526 assert(Preheader &&
"Preheader should exist!");
528 std::unique_ptr<MemorySSAUpdater> MSSAU;
530 MSSAU = std::make_unique<MemorySSAUpdater>(MSSA);
548 "Preheader must end with a side-effect-free terminator");
550 "Preheader must have a single successor");
578 auto *ExitBlock = L->getUniqueExitBlock();
581 assert(ExitBlock &&
"Should have a unique exit block!");
582 assert(L->hasDedicatedExits() &&
"Loop should have dedicated exits!");
584 Builder.CreateCondBr(Builder.getFalse(), L->getHeader(), ExitBlock);
590 for (
PHINode &
P : ExitBlock->phis()) {
595 P.setIncomingBlock(PredIndex, Preheader);
599 P.removeIncomingValueIf([](
unsigned Idx) {
return Idx != 0; },
602 assert((
P.getNumIncomingValues() == 1 &&
603 P.getIncomingBlock(PredIndex) == Preheader) &&
604 "Should have exactly one value and that's from the preheader!");
618 Builder.SetInsertPoint(Preheader->getTerminator());
619 Builder.CreateBr(ExitBlock);
621 Preheader->getTerminator()->eraseFromParent();
624 "Loop should have either zero or one exit blocks.");
626 Builder.SetInsertPoint(OldTerm);
627 Builder.CreateUnreachable();
628 Preheader->getTerminator()->eraseFromParent();
638 MSSAU->removeBlocks(DeadBlockSet);
656 for (
auto *
Block : L->blocks())
661 if (L->contains(Usr->getParent()))
667 "Unexpected user in reachable block");
678 DVR.getDebugLoc().get());
682 DVR.removeFromParent();
696 ExitBlock->getFirstInsertionPt();
697 assert(InsertDbgValueBefore != ExitBlock->end() &&
698 "There should be a non-PHI instruction in exit block, else these "
699 "instructions will have no parent.");
706 ExitBlock->insertDbgRecordBefore(DVR, InsertDbgValueBefore);
711 for (
auto *
Block : L->blocks())
712 Block->dropAllReferences();
726 BB->eraseFromParent();
733 if (
Loop *ParentLoop = L->getParentLoop()) {
735 assert(
I != ParentLoop->end() &&
"Couldn't find loop");
736 ParentLoop->removeChildLoop(
I);
739 assert(
I != LI->
end() &&
"Couldn't find loop");
748 auto *Latch = L->getLoopLatch();
749 assert(Latch &&
"multiple latches not yet supported");
750 auto *Header = L->getHeader();
751 Loop *OutermostLoop = L->getOutermostLoop();
756 std::unique_ptr<MemorySSAUpdater> MSSAU;
758 MSSAU = std::make_unique<MemorySSAUpdater>(MSSA);
771 if (L->isLoopExiting(Latch)) {
776 const unsigned ExitIdx = L->contains(BI->getSuccessor(0)) ? 1 : 0;
777 BasicBlock *ExitBB = BI->getSuccessor(ExitIdx);
780 Header->removePredecessor(Latch,
true);
783 auto *NewBI = Builder.CreateBr(ExitBB);
786 NewBI->copyMetadata(*BI, {LLVMContext::MD_dbg,
787 LLVMContext::MD_annotation});
789 BI->eraseFromParent();
800 auto *BackedgeBB =
SplitEdge(Latch, Header, &DT, &LI, MSSAU.get());
804 true, &DTU, MSSAU.get());
816 if (OutermostLoop != L)
830 if (!LatchBR || !L->isLoopExiting(Latch))
835 "At least one edge out of the latch must go to the header");
848 D.L->getHeader()->getParent()->printAsOperand(OS,
false);
849 return OS <<
" " << *
D.L;
859 if (!ExitingBranch) {
860 LLVM_DEBUG(
dbgs() <<
"estimateLoopTripCount: Failed to find exiting "
861 <<
"latch branch of required form in " <<
DbgLoop(L)
871 LLVM_DEBUG(
dbgs() <<
"estimateLoopTripCount: Failed to extract branch "
872 <<
"weights for " <<
DbgLoop(L) <<
"\n");
881 LLVM_DEBUG(
dbgs() <<
"estimateLoopTripCount: Failed because of zero exit "
882 <<
"probability for " <<
DbgLoop(L) <<
"\n");
891 if (ExitCount >= std::numeric_limits<unsigned>::max())
892 return std::numeric_limits<unsigned>::max();
896 LLVM_DEBUG(
dbgs() <<
"estimateLoopTripCount: Estimated trip count of " << TC
897 <<
" for " <<
DbgLoop(L) <<
"\n");
901std::optional<unsigned>
903 unsigned *EstimatedLoopInvocationWeight) {
936 if (EstimatedLoopInvocationWeight) {
937 uint64_t LoopWeight = 0, ExitWeight = 0;
944 *EstimatedLoopInvocationWeight = ExitWeight;
956 if (std::optional<unsigned> TC =
960 <<
"count of " << *TC <<
" for " <<
DbgLoop(L) <<
"\n");
969 Loop *L,
unsigned EstimatedTripCount,
970 std::optional<unsigned> EstimatedloopInvocationWeight) {
990 if (!EstimatedloopInvocationWeight)
994 unsigned LatchExitWeight = 1;
995 unsigned BackedgeTakenWeight = 0;
997 if (EstimatedTripCount != 0) {
998 LatchExitWeight = *EstimatedloopInvocationWeight;
999 BackedgeTakenWeight = (EstimatedTripCount - 1) * LatchExitWeight;
1004 std::swap(BackedgeTakenWeight, LatchExitWeight);
1017 bool FirstTargetIsLoop = LatchBranch->
getSuccessor(0) == L->getHeader();
1025 bool FirstTargetIsLoop = LatchBranch->
getSuccessor(0) == L->getHeader();
1031 bool ForFirstTarget) {
1032 uint64_t Weight0, Weight1;
1035 uint64_t Denominator = Weight0 + Weight1;
1036 if (Denominator == 0)
1038 if (!ForFirstTarget)
1044 assert(Src != Dst &&
"Passed in same source as destination");
1057 "Missing weights in branch_weights");
1063 Numerator += Weight;
1071 if (
Total == 0 ||
Total > std::numeric_limits<uint32_t>::max())
1078 bool ForFirstTarget) {
1081 if (!ForFirstTarget)
1095 const SCEV *InnerLoopBECountSC = SE.
getExitCount(InnerLoop, InnerLoopLatch);
1116 return Intrinsic::vector_reduce_add;
1118 return Intrinsic::vector_reduce_mul;
1120 return Intrinsic::vector_reduce_and;
1122 return Intrinsic::vector_reduce_or;
1124 return Intrinsic::vector_reduce_xor;
1129 return Intrinsic::vector_reduce_fadd;
1131 return Intrinsic::vector_reduce_fmul;
1133 return Intrinsic::vector_reduce_smax;
1135 return Intrinsic::vector_reduce_smin;
1137 return Intrinsic::vector_reduce_umax;
1139 return Intrinsic::vector_reduce_umin;
1143 return Intrinsic::vector_reduce_fmax;
1147 return Intrinsic::vector_reduce_fmin;
1149 return Intrinsic::vector_reduce_fmaximum;
1151 return Intrinsic::vector_reduce_fminimum;
1153 return Intrinsic::vector_reduce_fmax;
1155 return Intrinsic::vector_reduce_fmin;
1163 case Intrinsic::umin:
1164 return Intrinsic::vector_reduce_umin;
1165 case Intrinsic::umax:
1166 return Intrinsic::vector_reduce_umax;
1167 case Intrinsic::smin:
1168 return Intrinsic::vector_reduce_smin;
1169 case Intrinsic::smax:
1170 return Intrinsic::vector_reduce_smax;
1177 case Intrinsic::vector_reduce_fadd:
1178 return Instruction::FAdd;
1179 case Intrinsic::vector_reduce_fmul:
1180 return Instruction::FMul;
1181 case Intrinsic::vector_reduce_add:
1182 return Instruction::Add;
1183 case Intrinsic::vector_reduce_mul:
1184 return Instruction::Mul;
1185 case Intrinsic::vector_reduce_and:
1186 return Instruction::And;
1187 case Intrinsic::vector_reduce_or:
1188 return Instruction::Or;
1189 case Intrinsic::vector_reduce_xor:
1190 return Instruction::Xor;
1191 case Intrinsic::vector_reduce_smax:
1192 case Intrinsic::vector_reduce_smin:
1193 case Intrinsic::vector_reduce_umax:
1194 case Intrinsic::vector_reduce_umin:
1195 return Instruction::ICmp;
1196 case Intrinsic::vector_reduce_fmax:
1197 case Intrinsic::vector_reduce_fmin:
1198 case Intrinsic::vector_reduce_fmaximum:
1199 case Intrinsic::vector_reduce_fminimum:
1200 case Intrinsic::vector_reduce_fmaximumnum:
1201 case Intrinsic::vector_reduce_fminimumnum:
1202 return Instruction::FCmp;
1213 case Instruction::Add:
1214 return Intrinsic::vector_reduce_add;
1215 case Instruction::Mul:
1216 return Intrinsic::vector_reduce_mul;
1217 case Instruction::And:
1218 return Intrinsic::vector_reduce_and;
1219 case Instruction::Or:
1220 return Intrinsic::vector_reduce_or;
1221 case Instruction::Xor:
1222 return Intrinsic::vector_reduce_xor;
1223 case Instruction::FAdd:
1224 return Intrinsic::vector_reduce_fadd;
1225 case Instruction::FMul:
1226 return Intrinsic::vector_reduce_fmul;
1235 case Intrinsic::vector_reduce_umin:
1236 return Intrinsic::umin;
1237 case Intrinsic::vector_reduce_umax:
1238 return Intrinsic::umax;
1239 case Intrinsic::vector_reduce_smin:
1240 return Intrinsic::smin;
1241 case Intrinsic::vector_reduce_smax:
1242 return Intrinsic::smax;
1243 case Intrinsic::vector_reduce_fmin:
1244 return Intrinsic::minnum;
1245 case Intrinsic::vector_reduce_fmax:
1246 return Intrinsic::maxnum;
1247 case Intrinsic::vector_reduce_fminimum:
1248 return Intrinsic::minimum;
1249 case Intrinsic::vector_reduce_fmaximum:
1250 return Intrinsic::maximum;
1251 case Intrinsic::vector_reduce_fminimumnum:
1252 return Intrinsic::minimumnum;
1253 case Intrinsic::vector_reduce_fmaximumnum:
1254 return Intrinsic::maximumnum;
1263 return Intrinsic::umin;
1265 return Intrinsic::umax;
1267 return Intrinsic::smin;
1269 return Intrinsic::smax;
1273 return Intrinsic::minnum;
1277 return Intrinsic::maxnum;
1279 return Intrinsic::minimum;
1281 return Intrinsic::maximum;
1283 return Intrinsic::minimumnum;
1285 return Intrinsic::maximumnum;
1291 case Intrinsic::vector_reduce_smax:
1293 case Intrinsic::vector_reduce_smin:
1295 case Intrinsic::vector_reduce_umax:
1297 case Intrinsic::vector_reduce_umin:
1299 case Intrinsic::vector_reduce_fmax:
1301 case Intrinsic::vector_reduce_fmin:
1303 case Intrinsic::vector_reduce_fmaximum:
1305 case Intrinsic::vector_reduce_fminimum:
1307 case Intrinsic::vector_reduce_fmaximumnum:
1309 case Intrinsic::vector_reduce_fminimumnum:
1341 if (Ty->isIntOrIntVectorTy() ||
1347 return Builder.CreateIntrinsic(Ty, Id, {
Left,
Right},
nullptr,
1351 Value *Cmp = Builder.CreateCmp(Pred,
Left,
Right,
"rdx.minmax.cmp");
1367 Value *Result = Acc;
1368 for (
unsigned ExtractIdx = 0; ExtractIdx != VF; ++ExtractIdx) {
1370 Builder.CreateExtractElement(Src, Builder.getInt32(ExtractIdx));
1372 if (
Op != Instruction::ICmp &&
Op != Instruction::FCmp) {
1386 unsigned RdxOpcode,
Value *Acc,
1389 Type *EltTy = VTy->getElementType();
1390 Function *
F = Builder.GetInsertBlock()->getParent();
1394 unsigned MinElts = VTy->getElementCount().getKnownMinValue();
1395 Value *NumElts = Builder.CreateVScale(IdxTy);
1396 NumElts = Builder.CreateMul(NumElts, ConstantInt::get(IdxTy, MinElts));
1398 BasicBlock *EntryBB = Builder.GetInsertBlock();
1401 nullptr,
"rdx.exit");
1404 Builder.SetInsertPoint(EntryBB);
1405 Builder.CreateBr(LoopBB);
1407 Builder.SetInsertPoint(LoopBB);
1408 PHINode *
IV = Builder.CreatePHI(IdxTy, 2,
"rdx.iv");
1409 PHINode *AccPhi = Builder.CreatePHI(EltTy, 2,
"rdx.acc");
1410 IV->addIncoming(ConstantInt::get(IdxTy, 0), EntryBB);
1413 Value *Elt = Builder.CreateExtractElement(Vec,
IV);
1418 Builder.CreateNUWAdd(
IV, ConstantInt::get(IdxTy, 1),
"rdx.next");
1419 IV->addIncoming(NextIV, LoopBB);
1422 Value *
Done = Builder.CreateICmpEQ(NextIV, NumElts,
"rdx.done");
1423 Builder.CreateCondBr(
Done, ExitBB, LoopBB);
1442 Builder.SetInsertPoint(ExitBB->
begin());
1456 "Reduction emission only supported for pow2 vectors!");
1464 auto BuildShuffledOp = [&Builder, &
Op,
1466 Value *&TmpVec) ->
void {
1467 Value *Shuf = Builder.CreateShuffleVector(TmpVec, ShuffleMask,
"rdx.shuf");
1468 if (
Op != Instruction::ICmp &&
Op != Instruction::FCmp) {
1478 Value *TmpVec = Src;
1481 for (
unsigned stride = 1; stride < VF; stride <<= 1) {
1484 for (
unsigned j = 0; j < VF; j += stride << 1) {
1485 ShuffleMask[j] = j + stride;
1487 BuildShuffledOp(ShuffleMask, TmpVec);
1491 for (
unsigned i = VF; i != 1; i >>= 1) {
1493 for (
unsigned j = 0; j != i / 2; ++j)
1494 ShuffleMask[j] = i / 2 + j;
1497 std::fill(&ShuffleMask[i / 2], ShuffleMask.end(), -1);
1498 BuildShuffledOp(ShuffleMask, TmpVec);
1502 return Builder.CreateExtractElement(TmpVec, Builder.getInt32(0));
1507 bool Negative =
false;
1511 case Intrinsic::vector_reduce_add:
1512 case Intrinsic::vector_reduce_mul:
1513 case Intrinsic::vector_reduce_or:
1514 case Intrinsic::vector_reduce_xor:
1515 case Intrinsic::vector_reduce_and:
1516 case Intrinsic::vector_reduce_fadd:
1517 case Intrinsic::vector_reduce_fmul: {
1520 Flags.noSignedZeros());
1522 case Intrinsic::vector_reduce_umax:
1523 case Intrinsic::vector_reduce_umin:
1524 case Intrinsic::vector_reduce_smin:
1525 case Intrinsic::vector_reduce_smax: {
1529 case Intrinsic::vector_reduce_fmax:
1530 case Intrinsic::vector_reduce_fmaximum:
1533 case Intrinsic::vector_reduce_fmin:
1534 case Intrinsic::vector_reduce_fminimum: {
1535 bool PropagatesNaN = RdxID == Intrinsic::vector_reduce_fminimum ||
1536 RdxID == Intrinsic::vector_reduce_fmaximum;
1537 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1538 return (!Flags.noNaNs() && !PropagatesNaN)
1550 "nnan, nsz is expected to be set for FP min/max reduction.");
1558 auto getIdentity = [&]() {
1560 Builder.getFastMathFlags());
1589 return Builder.CreateFAddReduce(getIdentity(), Src);
1591 return Builder.CreateFMulReduce(getIdentity(), Src);
1601 case Intrinsic::vector_reduce_add:
1602 return Intrinsic::vp_reduce_add;
1603 case Intrinsic::vector_reduce_mul:
1604 return Intrinsic::vp_reduce_mul;
1605 case Intrinsic::vector_reduce_and:
1606 return Intrinsic::vp_reduce_and;
1607 case Intrinsic::vector_reduce_or:
1608 return Intrinsic::vp_reduce_or;
1609 case Intrinsic::vector_reduce_xor:
1610 return Intrinsic::vp_reduce_xor;
1611 case Intrinsic::vector_reduce_smax:
1612 return Intrinsic::vp_reduce_smax;
1613 case Intrinsic::vector_reduce_smin:
1614 return Intrinsic::vp_reduce_smin;
1615 case Intrinsic::vector_reduce_umax:
1616 return Intrinsic::vp_reduce_umax;
1617 case Intrinsic::vector_reduce_umin:
1618 return Intrinsic::vp_reduce_umin;
1619 case Intrinsic::vector_reduce_fmax:
1620 return Intrinsic::vp_reduce_fmax;
1621 case Intrinsic::vector_reduce_fmin:
1622 return Intrinsic::vp_reduce_fmin;
1623 case Intrinsic::vector_reduce_fmaximum:
1624 return Intrinsic::vp_reduce_fmaximum;
1625 case Intrinsic::vector_reduce_fminimum:
1626 return Intrinsic::vp_reduce_fminimum;
1627 case Intrinsic::vector_reduce_fadd:
1628 return Intrinsic::vp_reduce_fadd;
1629 case Intrinsic::vector_reduce_fmul:
1630 return Intrinsic::vp_reduce_fmul;
1638 "AnyOf and FindIV reductions are not supported.");
1643 Value *
Ops[] = {Iden, Src, Mask, EVL};
1644 return Builder.CreateIntrinsic(EltTy, VPID,
Ops);
1650 "Unexpected reduction kind");
1651 assert(Src->getType()->isVectorTy() &&
"Expected a vector type");
1652 assert(!Start->getType()->isVectorTy() &&
"Expected a scalar type");
1654 return B.CreateFAddReduce(Start, Src);
1661 "Unexpected reduction kind");
1662 assert(Src->getType()->isVectorTy() &&
"Expected a vector type");
1663 assert(!Start->getType()->isVectorTy() &&
"Expected a scalar type");
1668 Value *
Ops[] = {Start, Src, Mask, EVL};
1669 return Builder.CreateIntrinsic(EltTy, VPID,
Ops);
1673 bool IncludeWrapFlags) {
1681 const unsigned Opcode = Intersection->getOpcode();
1682 VecOp->copyIRFlags(Intersection, IncludeWrapFlags);
1683 for (
auto *V : VL) {
1687 if (OpValue ==
nullptr || Opcode == Instr->getOpcode())
1688 VecOp->andIRFlags(V);
1752 while (!WorkList.
empty()) {
1755 if (!L->contains(Curr))
1762 if (Visited.
insert(UI).second)
1795 BasicBlock *Preheader = L->getLoopPreheader();
1805 L->getExitingBlocks(ExitingBlocks);
1807 L->getUniqueExitBlocks(ExitBlocks);
1808 if (ExitBlocks.
size() != 1 || ExitingBlocks.
size() != 1)
1814 Value *Incoming =
P->getIncomingValueForBlock(ExitingBlocks[0]);
1820 for (
const RewritePhi &Phi : RewritePhiSet) {
1821 unsigned i = Phi.Ith;
1822 if (Phi.PN ==
P && (Phi.PN)->getIncomingValue(i) == Incoming) {
1830 if (!L->hasLoopInvariantOperands(
I))
1836 for (
auto *BB : L->blocks())
1838 return I.mayHaveSideEffects();
1852 if (!L->getLoopPreheader())
1854 if (Phi->getParent() != L->getHeader())
1864 BasicBlock *Preheader = L->getLoopPreheader();
1870 if (L->isLoopInvariant(
Op))
1877 !Rewriter.isSafeToExpandAt(ExitValue, Preheader->
getTerminator()))
1881 return !ExitValues.
empty();
1891 assert(L->isRecursivelyLCSSAForm(*DT, *LI) &&
1892 "Caller did not preserve LCSSA!");
1895 L->getUniqueExitBlocks(ExitBlocks);
1919 for (
unsigned i = 0; i != NumPreds; ++i) {
1932 if (!L->contains(Inst))
1949 if (!isa<PHINode>(U) && !isa<BinaryOperator>(U))
1951 BinaryOperator *B = dyn_cast<BinaryOperator>(U);
1952 if (B && B != ID.getInductionBinOp())
1964 PHINode *Phi = dyn_cast<PHINode>(U);
1965 if (Phi != PN && !checkIsIndPhi(Phi, L, SE, ID))
1970 if (
B != ID.getInductionBinOp())
1985 !Rewriter.isSafeToExpandAt(
1986 ExitValue, L->getLoopPreheader()->getTerminator())) {
2003 !OperandExitValues.
empty() ||
2004 Rewriter.isHighCostExpansion(ExitValue.
getPointer(), L,
2016 std::move(OperandExitValues));
2027 int NumReplaced = 0;
2030 for (
const RewritePhi &Phi : RewritePhiSet) {
2037 !LoopCanBeDel && Phi.HighCost)
2042 if (Phi.OperandExitValues.empty()) {
2043 ExitVal = Rewriter.expandCodeFor(Phi.ExpansionSCEV, Phi.PN->getType(),
2044 Phi.ExpansionPoint);
2048 for (
auto [Idx, ExitSCEV] : Phi.OperandExitValues)
2049 Clone->
setOperand(Idx, Rewriter.expandCodeFor(
2051 Phi.ExpansionPoint));
2052 Clone->
insertBefore(Phi.ExpansionPoint->getIterator());
2056 LLVM_DEBUG(
dbgs() <<
"rewriteLoopExitValues: AfterLoopVal = " << *ExitVal
2058 <<
" LoopVal = " << *Inst <<
"\n");
2065 if (
auto *EVL = LI->
getLoopFor(ExitInsn->getParent()))
2067 assert(EVL->contains(L) &&
"LCSSA breach detected!");
2094 Rewriter.clearInsertPoint();
2101template <
typename RangeT>
2111 assert(PreOrderLoops.
empty() &&
"Must start with an empty preorder walk.");
2113 "Must start with an empty preorder walk worklist.");
2117 PreOrderWorklist.
append(L->begin(), L->end());
2119 }
while (!PreOrderWorklist.
empty());
2121 Worklist.
insert(std::move(PreOrderLoops));
2122 PreOrderLoops.
clear();
2126template <
typename RangeT>
2149 PL->addChildLoop(&New);
2183 const SCEV *Step =
nullptr;
2184 for (
const SCEV *S : Exprs) {
2185 const SCEV *CurrentStep;
2186 if (!
match(S, m_scev_AffineAddRec(m_SCEV(), m_SCEV(CurrentStep),
2187 m_SpecificLoop(L))) ||
2188 (Step && Step != CurrentStep))
2219 const SCEV *NewHigh =
2222 LLVM_DEBUG(
dbgs() <<
"LAA: Expanded RT check for range to include "
2223 "outer loop in order to permit hoisting\n");
2232 << *Stride <<
'\n');
2248 Value *Start =
nullptr, *
End =
nullptr;
2253 Start = Exp.expandCodeFor(
Low, PtrArithTy,
Loc);
2254 End = Exp.expandCodeFor(
High, PtrArithTy,
Loc);
2257 Start = Builder.CreateFreeze(Start, Start->getName() +
".fr");
2258 End = Builder.CreateFreeze(
End,
End->getName() +
".fr");
2261 Stride ? Exp.expandCodeFor(Stride, Stride->getType(),
Loc) :
nullptr;
2263 return {Start,
End, StrideVal};
2275 transform(PointerChecks, std::back_inserter(ChecksWithBounds),
2281 return std::make_pair(
First, Second);
2284 return ChecksWithBounds;
2293 auto ExpandedChecks =
2299 Value *MemoryRuntimeCheck =
nullptr;
2302 for (
const auto &[
A,
B] : ExpandedChecks) {
2307 Type *PtrTy =
A.Start->getType();
2308 assert(
DL.getPointerTypeSizeInBits(PtrTy) ==
2309 DL.getPointerTypeSizeInBits(
B.Start->getType()) &&
2310 "Expected bounds with the same pointer size");
2324 Value *IsConflict = ChkBuilder.
CreateAnd(Cmp0, Cmp1,
"found.conflict");
2325 if (
A.StrideToCheck && CheckedStrides.
insert(
A.StrideToCheck).second) {
2327 A.StrideToCheck, ConstantInt::get(
A.StrideToCheck->getType(), 0),
2329 IsConflict = ChkBuilder.
CreateOr(IsConflict, IsNegativeStride);
2331 if (
B.StrideToCheck && CheckedStrides.
insert(
B.StrideToCheck).second) {
2333 B.StrideToCheck, ConstantInt::get(
B.StrideToCheck->getType(), 0),
2335 IsConflict = ChkBuilder.
CreateOr(IsConflict, IsNegativeStride);
2337 if (MemoryRuntimeCheck) {
2339 ChkBuilder.
CreateOr(MemoryRuntimeCheck, IsConflict,
"conflict.rdx");
2341 MemoryRuntimeCheck = IsConflict;
2344 Exp.eraseDeadInstructions(MemoryRuntimeCheck);
2345 return MemoryRuntimeCheck;
2356 Value *MemoryRuntimeCheck =
nullptr;
2358 auto &SE = *Expander.
getSE();
2362 for (
const auto &[SrcStart, SinkStart, AccessSize, NeedsFreeze] : Checks) {
2363 assert(IC * AccessSize > 0 &&
2364 "Threshold must be non-zero to use diff-check");
2365 Type *Ty = SinkStart->getType();
2366 const SCEV *TotalAccessSize = SE.getElementCount(Ty, VF * IC * AccessSize);
2368 SE.getMinusSCEV(TotalAccessSize, SE.getConstant(Ty, 1)), Ty,
Loc);
2374 Value *IsConflict = SeenCompares.
lookup({Diff, ThresholdMinusOne});
2381 ChkBuilder.
CreateSub(Diff, ConstantInt::get(Ty, 1)), ThresholdMinusOne,
2383 SeenCompares.
insert({{Diff, ThresholdMinusOne}, IsConflict});
2387 if (MemoryRuntimeCheck) {
2389 ChkBuilder.
CreateOr(MemoryRuntimeCheck, IsConflict,
"conflict.rdx");
2391 MemoryRuntimeCheck = IsConflict;
2395 return MemoryRuntimeCheck;
2398std::optional<IVConditionInfo>
2417 WorkList.
append(CondI->op_begin(), CondI->op_end());
2421 while (!WorkList.
empty()) {
2423 if (!
I || !L.contains(
I))
2432 if (LI->isVolatile() || LI->isAtomic())
2439 AccessesToCheck.
push_back(MemUse->getDefiningAccess());
2447 WorkList.
append(
I->op_begin(),
I->op_end());
2450 if (InstToDuplicate.
empty())
2454 L.getExitingBlocks(ExitingBlocks);
2455 auto HasNoClobbersOnPath =
2456 [&L, &
AA, &AccessedLocs, &ExitingBlocks, &InstToDuplicate,
2459 -> std::optional<IVConditionInfo> {
2471 while (!WorkList.
empty()) {
2473 if (!L.contains(Current))
2475 const auto &SeenIns = Seen.
insert(Current);
2476 if (!SeenIns.second)
2479 Info.PathIsNoop &=
all_of(
2480 *Current, [](
Instruction &
I) {
return !
I.mayHaveSideEffects(); });
2486 if (Seen.
size() < 2)
2494 while (!AccessesToCheck.
empty()) {
2496 auto SeenI = SeenAccesses.
insert(Current);
2501 if (SeenAccesses.
size() >= MSSAThreshold)
2513 AA.getModRefInfo(CurrentDef->getMemoryInst(),
Loc));
2518 for (
Use &U : Current->
uses())
2529 if (Info.PathIsNoop) {
2530 for (
auto *Exiting : ExitingBlocks) {
2534 if (L.contains(Succ))
2537 Info.PathIsNoop &= Succ->phis().empty() &&
2538 (!Info.ExitForPath || Info.ExitForPath == Succ);
2539 if (!Info.PathIsNoop)
2541 assert((!Info.ExitForPath || Info.ExitForPath == Succ) &&
2542 "cannot have multiple exit blocks");
2543 Info.ExitForPath = Succ;
2547 if (!Info.ExitForPath)
2548 Info.PathIsNoop =
false;
2550 Info.InstToDuplicate = std::move(InstToDuplicate);
2556 if (TI->getSuccessor(0) == TI->getSuccessor(1))
2559 if (
auto Info = HasNoClobbersOnPath(TI->getSuccessor(0), L.getHeader(),
2564 if (
auto Info = HasNoClobbersOnPath(TI->getSuccessor(1), L.getHeader(),
2576 assert(L.isInnermost() &&
"Expected innermost loop!");
2582 auto GetCompressedPtrSCEV = [&](
Value *Ptr,
2590 unsigned AccessSize =
DL.getTypeAllocSize(AccessTy).getFixedValue();
2592 m_scev_AffineAddRec(m_SCEV(), m_scev_SpecificInt(AccessSize),
2593 m_SpecificLoop(&L))))
2602 while (!Worklist.
empty()) {
2604 if (!Seen.
insert(U).second)
2610 if (!L.contains(UserI))
2617 Value *CurrentVal = U->get();
2621 if (
SI &&
SI->getValueOperand() == CurrentVal)
2631 const SCEVAddRecExpr *PtrAddRec = GetCompressedPtrSCEV(Ptr, AccessTy);
2638 auto LoopVariantOp = [&](
Value *V,
bool ) ->
Value * {
2639 return L.isLoopInvariant(V) ? nullptr : V;
2647 if (UserI->use_empty() ||
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo MachineBasicBlock::iterator InsertPt
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This is the interface for LLVM's primary stateless and local alias analysis.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXPORT_TEMPLATE
This file defines the DenseSet and SmallDenseSet classes.
This is the interface for a simple mod/ref and alias analysis over globals.
ManagedStatic< HTTPClientCleanup > Cleanup
Module.h This file contains the declarations for the Module class.
iv Induction Variable Users
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
SmallVector< MachineOperand, 4 > Cond
static cl::opt< bool, true > HoistRuntimeChecks("hoist-runtime-checks", cl::Hidden, cl::desc("Hoist inner loop runtime memory checks to outer loop if possible"), cl::location(VectorizerParams::HoistRuntimeChecks), cl::init(true))
static bool hasHardUserWithinLoop(const Loop *L, const Instruction *I)
static CondBrInst * getExpectedExitLoopLatchBranch(Loop *L)
Checks if L has an exiting latch branch.
static const char * LLVMLoopDisableLICM
static PointerBounds expandBounds(const RuntimeCheckingPtrGroup *CG, Loop *TheLoop, Instruction *Loc, SCEVExpander &Exp, bool HoistRuntimeChecks)
Expand code for the lower and upper bound of the pointer group CG in TheLoop.
static bool canLoopBeDeleted(Loop *L, SmallVector< RewritePhi, 8 > &RewritePhiSet)
static const SCEV * getCommonAffineStep(ArrayRef< const SCEV * > Exprs, const Loop *L)
Return a SCEV expression representing a common step if all of Exprs are affine AddRecs of L with the ...
static const char * LLVMLoopDisableNonforced
static bool collectOperandExitValues(Instruction *Inst, Loop *L, BasicBlock *ExitingBlock, ScalarEvolution *SE, SCEVExpander &Rewriter, OperandExitValueList &ExitValues)
static MDNode * createStringMetadata(Loop *TheLoop, StringRef Name, unsigned V)
Create MDNode for input string.
static std::optional< unsigned > estimateLoopTripCount(Loop *L)
static bool checkIsIndPhi(PHINode *Phi, Loop *L, ScalarEvolution *SE, InductionDescriptor &ID)
Checks if it is safe to call InductionDescriptor::isInductionPHI for Phi, and returns true if this Ph...
SmallVector< std::pair< unsigned, SCEVUse >, 2 > OperandExitValueList
static Intrinsic::ID getVPReductionIntrinsicID(Intrinsic::ID Id)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
#define INITIALIZE_PASS_DEPENDENCY(depName)
This file provides a priority worklist.
This file contains the declarations for profiling metadata utility functions.
This is the interface for a SCEV-based alias analysis.
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
SmallDenseMap< const PHINode *, PhiInfo, 16 > PhiMap
static const uint32_t IV[8]
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
Class for arbitrary precision integers.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Represent the analysis usage information of a pass.
LLVM_ABI AnalysisUsage & addRequiredID(const void *ID)
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Legacy wrapper pass to provide the BasicAAResult object.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
static LLVM_ABI BranchProbability getBranchProbability(uint64_t Numerator, uint64_t Denominator)
static constexpr BranchProbability getUnknown()
static constexpr BranchProbability getZero()
uint32_t getNumerator() const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ ICMP_ULT
unsigned less than
@ ICMP_SGE
signed greater or equal
Conditional Branch instruction.
BasicBlock * getSuccessor(unsigned i) const
Describes a conditional induction variable: an induction variable that is updated only on loop iterat...
LLVM_ABI SCEVUse getUnconditionalAddRec(ScalarEvolution &SE, const Loop &L) const
Returns an over-approximation of the conditional induction as a SCEVAddRec assuming the condition is ...
PHINode * getHeaderPHI() const
Returns the header PHI described by this descriptor.
PHINode * getBackedgePHI() const
Returns the backedge PHI that selects between StepInst and the HeaderPHI.
static LLVM_ABI Constant * getIntrinsicIdentity(Intrinsic::ID, Type *Ty)
static LLVM_ABI Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
static LLVM_ABI ConstantFP * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static LLVM_ABI ConstantFP * getInfinity(Type *Ty, bool Negative=false)
This is the shared class of boolean and integer constants.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
A parsed version of the target data layout string in and methods for querying it.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Identifies a unique instance of a variable.
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
iterator_range< iterator > children()
void applyUpdates(ArrayRef< UpdateType > Updates)
Inform the dominator tree about a sequence of CFG edge insertions and deletions and perform a batch u...
static constexpr UpdateKind Delete
static constexpr UpdateKind Insert
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Convenience struct for specifying and reasoning about fast-math flags.
bool noSignedZeros() const
void applyUpdates(ArrayRef< UpdateT > Updates)
Submit updates to all available trees.
Legacy wrapper pass to provide the GlobalsAAResult object.
Common base class shared among various IRBuilders.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNull=false)
Value * CreateFreeze(Value *V, const Twine &Name="")
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="", bool IsDisjoint=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
A struct for saving information about induction variables.
static LLVM_ABI bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, ArrayRef< const SCEVPredicate * > NoWrapPreds={}, const SCEV *Expr=nullptr, SmallVectorImpl< Instruction * > *CastsToIgnore=nullptr)
Returns true if Phi is an induction in the loop L.
InstSimplifyFolder - Use InstructionSimplify to fold operations to existing values.
LLVM_ABI Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
LLVM_ABI bool mayHaveSideEffects() const LLVM_READONLY
Return true if the instruction may have side effects.
iterator_range< user_iterator > users()
This is an important class for using LLVM in a threaded context.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within this loop.
typename std::vector< Loop * >::const_iterator iterator
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
BlockT * getHeader() const
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
bool hasNoExitBlocks(const LoopT &L) const
Return true if L does not have any exit blocks.
void removeBlock(BlockT *BB)
This method completely removes BB from all data structures, including all of the Loop objects it is n...
LoopT * removeLoop(iterator I)
This removes the specified top-level loop from this loop info object.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
void destroy(LoopT *L)
Destroy a loop that has been removed from the LoopInfo nest.
The legacy pass manager's analysis pass to compute loop information.
bool replacementPreservesLCSSAForm(Instruction *From, Value *To)
Returns true if replacing From with To everywhere is guaranteed to preserve LCSSA form.
LLVM_ABI void erase(Loop *L)
Update LoopInfo after removing the last backedge from a loop.
Represents a single loop in the control flow graph.
LLVM_ABI void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
LLVM_ABI MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
const MDOperand & getOperand(unsigned I) const
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
Tracking metadata reference owned by Metadata.
LLVM_ABI StringRef getString() const
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
BasicBlock * getBlock() const
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
Legacy analysis pass which computes MemorySSA.
Encapsulates MemorySSA, including all data associated with memory accesses.
LLVM_ABI void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void setIncomingValue(unsigned i, Value *V)
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
bool insert(const T &X)
Insert a new element into the PriorityWorklist.
static bool isAnyOfRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cond,x,y) where one of (x,...
static bool isFindRecurrenceKind(RecurKind Kind)
static bool isMinMaxRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is any min/max kind.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Legacy wrapper pass to provide the SCEVAAResult object.
This node represents a polynomial recurrence on the trip count of the specified loop.
This class uses information about analyze scalars to rewrite expressions in canonical form.
ScalarEvolution * getSE()
LLVM_ABI Value * expandCodeFor(SCEVUse SH, Type *Ty, BasicBlock::iterator I)
Insert code to directly compute the specified SCEV expression into the program.
LLVM_ABI void eraseDeadInstructions(Value *Root)
Remove inserted instructions that are dead, e.g.
static const SCEV * rewrite(SCEVUse Scev, ScalarEvolution &SE, ValueToSCEVMapTy &Map)
This class represents an analyzed expression in the program.
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
const DataLayout & getDataLayout() const
Return the DataLayout associated with the module this SCEV instance is operating on.
LLVM_ABI bool isKnownNonNegative(const SCEV *S)
Test if the given expression is known to be non-negative.
LLVM_ABI bool isLoopEntryGuardedByCond(const Loop *L, CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS)
Test whether entry to the loop is protected by a conditional between LHS and RHS.
const SCEV * getZero(Type *Ty)
Return a SCEV for the constant 0 of a specific type.
LLVM_ABI const SCEV * getConstant(ConstantInt *V)
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
LLVM_ABI void forgetLoop(const Loop *L)
This method should be called by the client when it has changed a loop in a way that may effect Scalar...
LLVM_ABI bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
LLVM_ABI LoopDisposition getLoopDisposition(const SCEV *S, const Loop *L)
Return the "disposition" of the given SCEV with respect to the given loop.
LLVM_ABI bool isSCEVable(Type *Ty) const
Test if values of the given type are analyzable within the SCEV framework.
LLVM_ABI void forgetValue(Value *V)
This method should be called by the client when it has changed a value in a way that may effect its v...
LLVM_ABI void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
LLVM_ABI SCEVUse getSCEVAtExit(const SCEV *S, const Loop *L, const BasicBlock *ExitingBlock)
Return the SCEV expression at the specified loop exit.
LoopDisposition
An enum describing the relationship between a SCEV and a loop.
@ LoopInvariant
The SCEV is loop-invariant.
LLVM_ABI bool isAvailableAtLoopEntry(const SCEV *S, const Loop *L)
Determine if the SCEV can be evaluated at loop's entry.
LLVM_ABI const SCEV * getExitCount(const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
Return the number of times the backedge executes before the given exit would be taken; if not exactly...
LLVM_ABI const SCEV * applyLoopGuards(const SCEV *Expr, const Loop *L)
Try to apply information from loop guards for L to Expr.
Implements a dense probed hash-table based set with some number of buckets stored inline.
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Provides information about what library functions are available for the current target.
Value handle that tracks a Value across RAUW.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
LLVM_ABI bool isScalableTy() const
Return true if this is a type whose size is a known multiple of vscale.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
bool match(Val *V, const Pattern &P)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
LLVM_ABI Value * createSimpleReduction(IRBuilderBase &B, Value *Src, RecurKind RdxKind)
Create a reduction of the given vector.
LLVM_ABI std::optional< ElementCount > getOptionalElementCountLoopAttribute(const Loop *TheLoop)
Find a combination of metadata ("llvm.loop.vectorize.width" and "llvm.loop.vectorize....
LLVM_ABI bool collectCompressedPtrs(DenseMap< Value *, const SCEVAddRecExpr * > &CompressedPtrs, const Loop &L, const ConditionalInductionDescriptor &CondID, ScalarEvolution &SE)
Collect pointer values used by loads and stores whose addresses are derived from the conditional indu...
LLVM_ABI BranchProbability getBranchProbability(CondBrInst *B, bool ForFirstTarget)
Based on branch weight metadata, return either:
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
LLVM_ABI Value * addRuntimeChecks(Instruction *Loc, Loop *TheLoop, const SmallVectorImpl< RuntimePointerCheck > &PointerChecks, SCEVExpander &Expander, bool HoistRuntimeChecks=false)
Add code that checks at runtime if the accessed arrays in PointerChecks overlap.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI std::optional< unsigned > getLoopEstimatedTripCount(Loop *L, unsigned *EstimatedLoopInvocationWeight=nullptr)
Return either:
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicOp(Intrinsic::ID RdxID)
Returns the min/max intrinsic used when expanding a min/max reduction.
LLVM_ABI bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
LLVM_ABI bool isKnownNonPositiveInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always non-positive in loop L.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
LLVM_ABI void setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I, StringRef PassName, const Function *F=nullptr)
Like setExplicitlyUnknownBranchWeights(...), but only sets unknown branch weights in the new instruct...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void appendReversedLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
auto successors(const MachineBasicBlock *BB)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
LLVM_ABI void initializeLoopPassPass(PassRegistry &)
Manually defined generic "LoopPass" dependency initialization.
constexpr from_range_t from_range
LLVM_ABI bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
LLVM_ABI Value * getReductionIdentity(Intrinsic::ID RdxID, Type *Ty, FastMathFlags FMF)
Given information about an @llvm.vector.reduce.
SCEVUseT< const SCEV * > SCEVUse
LLVM_ABI std::optional< MDNode * > makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef< StringRef > FollowupAttrs, const char *InheritOptionsAttrsPrefix="", bool AlwaysNew=false)
Create a new loop identifier for a loop created from a loop transformation.
LLVM_ABI unsigned getArithmeticReductionInstruction(Intrinsic::ID RdxID)
Returns the arithmetic instruction opcode used when expanding a reduction.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
std::pair< const RuntimeCheckingPtrGroup *, const RuntimeCheckingPtrGroup * > RuntimePointerCheck
A memcheck which made up of a pair of grouped pointers.
LLVM_ABI char & LoopSimplifyID
LLVM_ABI Value * createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left, Value *Right)
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
LLVM_ABI SmallVector< BasicBlock *, 16 > collectChildrenInLoop(DominatorTree *DT, DomTreeNode *N, const Loop *CurLoop)
Does a BFS from a given node to all of its children inside a given loop.
LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, unsigned V=0)
Set input string into loop metadata by keeping other values intact.
LLVM_ABI bool cannotBeMaxInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE, bool Signed)
Returns true if S is defined and never is equal to signed/unsigned max.
LLVM_ABI void setBranchWeights(Instruction &I, ArrayRef< uint32_t > Weights, bool IsExpected, bool ElideAllZero=false)
Create a new branch_weights metadata node and add or overwrite a prof metadata reference to instructi...
DomTreeNodeBase< BasicBlock > DomTreeNode
constexpr T divideNearest(U Numerator, V Denominator)
Returns (Numerator / Denominator) rounded by round-half-up.
LLVM_ABI TransformationMode hasVectorizeTransformation(const Loop *L)
auto dyn_cast_or_null(const Y &Val)
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
LLVM_ABI SmallVector< Instruction *, 8 > findDefsUsedOutsideOfLoop(Loop *L)
Returns the instructions that use values defined in the loop.
auto reverse(ContainerTy &&C)
LLVM_ABI constexpr Intrinsic::ID getReductionIntrinsicID(RecurKind RK)
Returns the llvm.vector.reduce intrinsic that corresponds to the recurrence kind.
LLVM_ABI bool isMustProgress(const Loop *L)
Return true if this loop can be assumed to make progress.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI void setBranchProbability(CondBrInst *B, BranchProbability P, bool ForFirstTarget)
Set branch weight metadata for B to indicate that P and 1 - P are the probabilities of control flowin...
bool isModSet(const ModRefInfo MRI)
LLVM_ABI TransformationMode hasUnrollAndJamTransformation(const Loop *L)
LLVM_ABI void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, LoopInfo *LI, MemorySSA *MSSA=nullptr)
This function deletes dead loops.
bool hasIrregularType(Type *Ty, const DataLayout &DL)
A helper function that returns true if the given type is irregular.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI bool hasDisableAllTransformsHint(const Loop *L)
Look for the loop attribute that disables all transformation heuristic.
LLVM_TEMPLATE_ABI void appendLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
LLVM_ABI cl::opt< unsigned > SCEVCheapExpansionBudget
LLVM_ABI Value * getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op, TargetTransformInfo::ReductionShuffle RS, RecurKind MinMaxKind=RecurKind::None)
Generates a vector reduction using shufflevectors to reduce the value.
LLVM_ABI TransformationMode hasUnrollTransformation(const Loop *L)
LLVM_ABI BranchProbability getLoopProbability(Loop *L)
Based on branch weight metadata, return either:
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
LLVM_ABI TransformationMode hasDistributeTransformation(const Loop *L)
T * find_singleton(R &&Range, Predicate P, bool AllowRepeats=false)
Return the single value in Range that satisfies P(<member of Range> *, AllowRepeats)->T * returning n...
LLVM_ABI void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE, LoopInfo &LI, MemorySSA *MSSA)
Remove the backedge of the specified loop.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI void getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
LLVM_ABI void propagateIRFlags(Value *I, ArrayRef< Value * > VL, Value *OpValue=nullptr, bool IncludeWrapFlags=true)
Get the intersection (logical and) of all of the potential IR flags of each scalar operation (VL) tha...
LLVM_ABI bool isKnownPositiveInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always positive in loop L.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
LLVM_ABI std::optional< int > getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name)
Find named metadata for a loop with an integer value.
LLVM_ABI bool setLoopProbability(Loop *L, BranchProbability P)
Set branch weight metadata for the latch of L to indicate that, at the end of any iteration,...
LLVM_ABI BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
This method introduces at least one new basic block into the function and moves some of the predecess...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
LLVM_ABI CmpInst::Predicate getMinMaxReductionPredicate(RecurKind RK)
Returns the comparison predicate used when expanding a min/max reduction.
LLVM_ABI TransformationMode hasLICMVersioningTransformation(const Loop *L)
TransformationMode
The mode sets how eager a transformation should be applied.
@ TM_Unspecified
The pass can use heuristics to determine whether a transformation should be applied.
@ TM_SuppressedByUser
The transformation must not be applied.
@ TM_ForcedByUser
The transformation was directed by the user, e.g.
@ TM_Disable
The transformation should not be applied.
@ TM_Enable
The transformation should be applied without considering a cost model.
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
LLVM_ABI bool hasDisableLICMTransformsHint(const Loop *L)
Look for the loop attribute that disables the LICM transformation heuristics.
template LLVM_TEMPLATE_ABI void appendLoopsToWorklist< Loop & >(Loop &L, SmallPriorityWorklist< Loop *, 4 > &Worklist)
LLVM_ABI Intrinsic::ID getReductionForBinop(Instruction::BinaryOps Opc)
Returns the reduction intrinsic id corresponding to the binary operation.
RecurKind
These are the kinds of recurrences that we support.
@ UMin
Unsigned integer min implemented in terms of select(cmp()).
@ FMinimumNum
FP min with llvm.minimumnum semantics.
@ Or
Bitwise or logical OR of integers.
@ FMaxSelectNoFMF
FMax as select(cmp()) lacking nnan or nsz, on IEEE types with IEEE denormals.
@ FMinimum
FP min with llvm.minimum semantics.
@ FMaxNum
FP max with llvm.maxnum semantics including NaNs.
@ Mul
Product of integers.
@ FSub
Subtraction of floats.
@ FAddChainWithSubs
A chain of fadds and fsubs.
@ Xor
Bitwise or logical XOR of integers.
@ FMax
FP max as select(cmp()) with nnan/nsz, or llvm.maxnum.
@ FMinSelectNoFMF
FMin as select(cmp()) lacking nnan or nsz, on IEEE types with IEEE denormals.
@ FMaximum
FP max with llvm.maximum semantics.
@ FMulAdd
Sum of float products with llvm.fmuladd(a * b + sum).
@ SMax
Signed integer max implemented in terms of select(cmp()).
@ And
Bitwise or logical AND of integers.
@ SMin
Signed integer min implemented in terms of select(cmp()).
@ FMin
FP min as select(cmp()) with nnan/nsz, or llvm.minnum.
@ FMinNum
FP min with llvm.minnum semantics including NaNs.
@ Sub
Subtraction of integers.
@ AddChainWithSubs
A chain of adds and subs.
@ FMaximumNum
FP max with llvm.maximumnum semantics.
@ UMax
Unsigned integer max implemented in terms of select(cmp()).
LLVM_ABI Value * getRecurrenceIdentity(RecurKind K, Type *Tp, FastMathFlags FMF)
Given information about an recurrence kind, return the identity for the @llvm.vector....
LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the specified block at the specified instruction.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
LLVM_ABI bool formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Ensure that all exit blocks of the loop are dedicated exits.
DenseMap< const Value *, SCEVUse > ValueToSCEVMapTy
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ABI bool isKnownNegativeInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always negative in loop L.
LLVM_ABI StringRef getLoopVectorizeKindPrefix(const Loop *L)
Return a short prefix describing the loop's vectorizer origin based on the llvm.loop....
constexpr unsigned BitWidth
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM_ABI Value * expandReductionViaLoop(IRBuilderBase &Builder, Value *Vec, unsigned RdxOpcode, Value *Acc, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Expand a scalable vector reduction into a runtime loop that applies RdxOpcode element by element,...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool setLoopEstimatedTripCount(Loop *L, unsigned EstimatedTripCount, std::optional< unsigned > EstimatedLoopInvocationWeight=std::nullopt)
Set llvm.loop.estimated_trip_count with the value EstimatedTripCount in the loop metadata of L.
LLVM_ABI bool extractBranchWeights(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Extract branch weights from MD_prof metadata.
LLVM_ABI const char * LLVMLoopEstimatedTripCount
Profile-based loop metadata that should be accessed only by using llvm::getLoopEstimatedTripCount and...
LLVM_ABI RuntimeCheckBounds getRuntimeCheckBounds(const RuntimeCheckingPtrGroup *CG, const Loop *TheLoop, ScalarEvolution &SE, bool HoistRuntimeChecks)
Return the bounds of CG in TheLoop.
LLVM_ABI bool hasIterationCountInvariantInParent(Loop *L, ScalarEvolution &SE)
Check inner loop (L) backedge count is known to be invariant on all iterations of its outer loop.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isAlmostDeadIV(PHINode *IV, BasicBlock *LatchBlock, Value *Cond)
Return true if the induction variable IV in a Loop whose latch is LatchBlock would become dead if the...
auto predecessors(const MachineBasicBlock *BB)
LLVM_ABI int rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, ScalarEvolution *SE, const TargetTransformInfo *TTI, SCEVExpander &Rewriter, DominatorTree *DT, ReplaceExitVal ReplaceExitValue, SmallVector< WeakTrackingVH, 16 > &DeadInsts)
If the final value of any expressions that are recurrent in the loop can be computed,...
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
LLVM_ABI Value * createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind, Value *Src, Value *Start)
Create an ordered reduction intrinsic using the given recurrence kind RdxKind.
LLVM_ABI RecurKind getMinMaxReductionRecurKind(Intrinsic::ID RdxID)
Returns the recurence kind used when expanding a min/max reduction.
LLVM_ABI BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the edge connecting the specified blocks, and return the newly created basic block between From...
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI std::optional< IVConditionInfo > hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold, const MemorySSA &MSSA, AAResults &AA)
Check if the loop header has a conditional branch that is not loop-invariant, because it involves loa...
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
LLVM_ABI bool cannotBeMinInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE, bool Signed)
Returns true if S is defined and never is equal to signed/unsigned min.
LLVM_ABI bool isKnownNonNegativeInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always non-negative in loop L.
LLVM_ABI Value * addDiffRuntimeChecks(Instruction *Loc, ArrayRef< PointerDiffInfo > Checks, SCEVExpander &Expander, ElementCount VF, unsigned IC)
LLVM_ABI Value * getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, unsigned Op, RecurKind MinMaxKind=RecurKind::None)
Generates an ordered vector reduction using extracts to reduce the value.
LLVM_ABI MDNode * findOptionMDForLoopID(MDNode *LoopID, StringRef Name)
Find and return the loop attribute node for the attribute Name in LoopID.
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicID(Intrinsic::ID IID)
Returns the llvm.vector.reduce min/max intrinsic that corresponds to the intrinsic op.
LLVM_ABI Loop * cloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM, LoopInfo *LI, LPPassManager *LPM)
Recursively clone the specified loop and all of its children, mapping the blocks with the specified m...
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
IR Values for the lower and upper bounds of a pointer evolution.
TrackingVH< Value > Start
OperandExitValueList OperandExitValues
RewritePhi(PHINode *P, unsigned I, SCEVUse Val, Instruction *ExpansionPt, bool H, OperandExitValueList OpExitValues={})
Instruction * ExpansionPoint
Struct to hold information about a partially invariant condition.
SCEV bounds of a pointer group: the first accessed byte, the last accessed byte plus one,...
unsigned AddressSpace
Address space of the involved pointers.
bool NeedsFreeze
Whether the pointer needs to be frozen after expansion, e.g.
const SCEV * High
The SCEV expression which represents the upper bound of all the pointers in this group.
const SCEV * Low
The SCEV expression which represents the lower bound of all the pointers in this group.
SCEVPtrT getPointer() const