Lines Matching +full:isa +full:- +full:base
1 //===---- Delinearization.cpp - MultiDimensional Index Delinearization ----===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 // use the on-demand SCEVAddRecExpr::delinearize() function.
14 //===----------------------------------------------------------------------===//
40 return isa<UndefValue>(SU->getValue());
57 Strides.push_back(AR->getStepRecurrence(SE));
71 if (isa<SCEVUnknown>(S) || isa<SCEVMulExpr>(S) ||
72 isa<SCEVSignExtendExpr>(S)) {
96 if (isa<SCEVAddRecExpr>(S)) {
134 for (const auto *Op : Mul->operands()) {
136 if (Unknown && !isa<CallInst>(Unknown->getValue())) {
201 int Last = Terms.size() - 1;
208 for (const SCEV *Op : M->operands())
209 if (!isa<SCEVConstant>(Op))
225 if (!R->isZero())
232 erase_if(Terms, [](const SCEV *E) { return isa<SCEVConstant>(E); });
245 if (SCEVExprContains(T, [](const SCEV *S) { return isa<SCEVUnknown>(S); }))
254 return Expr->getNumOperands();
259 if (isa<SCEVConstant>(T))
262 if (isa<SCEVUnknown>(T))
267 for (const SCEV *Op : M->operands())
268 if (!isa<SCEVConstant>(Op))
309 if (!Q->isZero())
349 if (!AR->isAffine())
353 int Last = Sizes.size() - 1;
354 for (int i = Last; i >= 0; i--) {
372 // Bail out if the byte offset is non-zero.
373 if (!R->isZero()) {
401 /// is the offset start of the array. The SCEV->delinearize algorithm computes
403 /// expressions in the stride and base of a SCEV corresponding to the
404 /// computation of a GCD (greatest common divisor) of base and stride. When
405 /// SCEV->delinearize fails, it returns the SCEV unchanged.
421 /// From this SCEV, we are able to say that the base offset of the access is %A
425 /// CHECK: Base offset: %A
427 /// and then SCEV->delinearize determines the size of some of the dimensions of
447 /// loops, calling SCEV->delinearize on that and printing the results.
493 for (unsigned i = 1; i < GEP->getNumOperands(); i++) {
494 const SCEV *Expr = SE.getSCEV(GEP->getOperand(i));
496 Ty = GEP->getSourceElementType();
498 if (Const->getValue()->isZero()) {
515 Sizes.push_back(ArrayTy->getNumElements());
517 Ty = ArrayTy->getElementType();
534 // Check that the two size arrays are non-empty and equal in length and
543 // Check that for identical base pointers we do not miss index offsets
545 Value *SrcBasePtr = SrcGEP->getOperand(0)->stripPointerCasts();
547 dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFn));
548 if (!SrcBase || SrcBasePtr != SrcBase->getValue()) {
564 O << "Delinearization on function " << F->getName() << ":\n";
567 if (!isa<StoreInst>(&Inst) && !isa<LoadInst>(&Inst) &&
568 !isa<GetElementPtrInst>(&Inst))
574 for (Loop *L = LI->getLoopFor(BB); L != nullptr; L = L->getParentLoop()) {
575 const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(&Inst), L);
578 dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFn));
579 // Do not delinearize if we cannot find the base pointer.
582 AccessFn = SE->getMinusSCEV(AccessFn, BasePointer);
586 O << "In Loop with Header: " << L->getHeader()->getName() << "\n";
590 delinearize(*SE, AccessFn, Subscripts, Sizes, SE->getElementSize(&Inst));
597 O << "Base offset: " << *BasePointer << "\n";
600 for (int i = 0; i < Size - 1; i++)
602 O << " with elements of " << *Sizes[Size - 1] << " bytes.\n";