|
Polly 23.0.0git
|
Translate a SCEV to an isl::pw_aff and the domain on which it is invalid. More...
#include <SCEVAffinator.h>
Public Member Functions | |
| SCEVAffinator (Scop *S, llvm::LoopInfo &LI) | |
| PWACtx | getPwAff (const llvm::SCEV *E, llvm::BasicBlock *BB=nullptr, RecordedAssumptionsTy *RecordedAssumptions=nullptr, bool IsInsideDomain=true) |
| Translate a SCEV to an isl::pw_aff. | |
| void | takeNonNegativeAssumption (PWACtx &PWAC, RecordedAssumptionsTy *RecordedAssumptions=nullptr) |
Take the assumption that PWAC is non-negative. | |
| void | interpretAsUnsigned (PWACtx &PWAC, unsigned Width) |
Interpret the PWA in PWAC as an unsigned value. | |
| bool | hasNSWAddRecForLoop (llvm::Loop *L) const |
Check an <nsw> AddRec for the loop L is cached. | |
| llvm::LoopInfo * | getLI () const |
| Return the LoopInfo used by the object. | |
Private Types | |
| using | CacheKey = std::pair<const llvm::SCEV *, llvm::BasicBlock *> |
| Key to identify cached expressions. | |
Private Member Functions | |
| llvm::Loop * | getScope () |
| Return the loop for the current block if any. | |
| PWACtx | getPWACtxFromPWA (isl::pw_aff PWA) |
Return a PWACtx for PWA that is always valid. | |
| isl::pw_aff | addModuloSemantic (isl::pw_aff PWA, llvm::Type *ExprType) const |
Compute the non-wrapping version of PWA for type ExprType. | |
| PWACtx | checkForWrapping (const llvm::SCEV *Expr, PWACtx PWAC) const |
If Expr might cause an integer wrap record an assumption. | |
| bool | computeModuloForExpr (const llvm::SCEV *Expr) |
| Whether to track the value of this expression precisely, rather than assuming it won't wrap. | |
| PWACtx | visit (const llvm::SCEV *E) |
| PWACtx | visitConstant (const llvm::SCEVConstant *E) |
| PWACtx | visitVScale (const llvm::SCEVVScale *E) |
| PWACtx | visitPtrToAddrExpr (const llvm::SCEVPtrToAddrExpr *E) |
| PWACtx | visitPtrToIntExpr (const llvm::SCEVPtrToIntExpr *E) |
| PWACtx | visitTruncateExpr (const llvm::SCEVTruncateExpr *E) |
| PWACtx | visitZeroExtendExpr (const llvm::SCEVZeroExtendExpr *E) |
| PWACtx | visitSignExtendExpr (const llvm::SCEVSignExtendExpr *E) |
| PWACtx | visitAddExpr (const llvm::SCEVAddExpr *E) |
| PWACtx | visitMulExpr (const llvm::SCEVMulExpr *E) |
| PWACtx | visitUDivExpr (const llvm::SCEVUDivExpr *E) |
| PWACtx | visitAddRecExpr (const llvm::SCEVAddRecExpr *E) |
| PWACtx | visitSMaxExpr (const llvm::SCEVSMaxExpr *E) |
| PWACtx | visitSMinExpr (const llvm::SCEVSMinExpr *E) |
| PWACtx | visitUMaxExpr (const llvm::SCEVUMaxExpr *E) |
| PWACtx | visitUMinExpr (const llvm::SCEVUMinExpr *E) |
| PWACtx | visitSequentialUMinExpr (const llvm::SCEVSequentialUMinExpr *E) |
| PWACtx | visitUnknown (const llvm::SCEVUnknown *E) |
| PWACtx | visitSDivInstruction (llvm::Instruction *SDiv) |
| PWACtx | visitSRemInstruction (llvm::Instruction *SRem) |
| PWACtx | complexityBailout () |
Private Attributes | |
| llvm::DenseMap< CacheKey, PWACtx > | CachedExpressions |
| Map to remembered cached expressions. | |
| Scop * | S |
| isl::ctx | Ctx |
| unsigned | NumIterators |
| llvm::ScalarEvolution & | SE |
| llvm::LoopInfo & | LI |
| llvm::BasicBlock * | BB |
| bool | IsInsideDomain = true |
Whether the evaluation takes place only when BB's domain has already been checked. | |
| RecordedAssumptionsTy * | RecordedAssumptions = nullptr |
| const llvm::DataLayout & | TD |
| Target data for element size computing. | |
Friends | |
| struct | llvm::SCEVVisitor< SCEVAffinator, PWACtx > |
Translate a SCEV to an isl::pw_aff and the domain on which it is invalid.
Definition at line 30 of file SCEVAffinator.h.
|
private |
Key to identify cached expressions.
Definition at line 67 of file SCEVAffinator.h.
| SCEVAffinator::SCEVAffinator | ( | Scop * | S, |
| llvm::LoopInfo & | LI ) |
Definition at line 84 of file SCEVAffinator.cpp.
References Ctx, LI, S, SE, and TD.
Referenced by llvm::SCEVVisitor< SCEVAffinator, PWACtx >.
|
private |
Compute the non-wrapping version of PWA for type ExprType.
| PWA | The piece-wise affine function that might wrap. |
| Type | The type of the SCEV that was translated to PWA. |
PWA modulo the size constraints of ExprType. Definition at line 162 of file SCEVAffinator.cpp.
References isl::checked::pw_aff::add(), Ctx, Domain, isl::checked::pw_aff::domain(), getWidthExpValOnDomain(), isl::val::int_from_ui(), isl::checked::manage(), isl::checked::multi_pw_aff::sub(), and TD.
Referenced by checkForWrapping(), and visit().
If Expr might cause an integer wrap record an assumption.
| Expr | The SCEV expression that might wrap. |
| PWAC | The isl representation of Expr with the invalid domain. |
PWAC with a possibly adjusted domain. Definition at line 134 of file SCEVAffinator.cpp.
References addModuloSemantic(), any(), polly::AS_RESTRICTION, BB, isl::checked::set::coalesce(), getNoWrapFlags(), IgnoreIntegerWrapping(), isl::checked::set::is_empty(), isl::checked::set::params(), polly::recordAssumption(), RecordedAssumptions, isl::checked::set::unite(), and polly::WRAPPING.
Referenced by visit().
|
private |
Definition at line 581 of file SCEVAffinator.cpp.
References BB, polly::COMPLEXITY, S, SE, and visit().
Referenced by visitAddExpr(), visitMulExpr(), visitSMaxExpr(), and visitSMinExpr().
|
private |
Whether to track the value of this expression precisely, rather than assuming it won't wrap.
Definition at line 190 of file SCEVAffinator.cpp.
References MaxSmallBitWidth, and TD.
Referenced by visit(), visitTruncateExpr(), and visitZeroExtendExpr().
|
inline |
Return the LoopInfo used by the object.
Definition at line 63 of file SCEVAffinator.h.
References LI.
|
private |
Return a PWACtx for PWA that is always valid.
Definition at line 113 of file SCEVAffinator.cpp.
References Ctx, isl::set::empty(), and NumIterators.
Referenced by visit(), visitConstant(), and visitUnknown().
| PWACtx SCEVAffinator::getPwAff | ( | const llvm::SCEV * | E, |
| llvm::BasicBlock * | BB = nullptr, | ||
| RecordedAssumptionsTy * | RecordedAssumptions = nullptr, | ||
| bool | IsInsideDomain = true ) |
Translate a SCEV to an isl::pw_aff.
| E | The expression that is translated. |
| BB | The block in which E is executed. |
| RecordedAssumptions | If set, assumptions that make the translation valid are added here. |
| IsInsideDomain | If true, assumptions only need to apply during the execution of BB. That is, when we know that we are in its domain. Must be false if the SCEV is evaluated outside a ScopStmt, or for code that computes the domain (since while doing that, we don't know whether we are in the domain yet). |
E in Domain. Definition at line 117 of file SCEVAffinator.cpp.
References BB, IsInsideDomain, isl_set_free(), isl_set_n_dim(), NumIterators, RecordedAssumptions, S, and visit().
|
private |
Return the loop for the current block if any.
Definition at line 88 of file SCEVAffinator.cpp.
Referenced by visit(), visitSDivInstruction(), visitSRemInstruction(), and visitUnknown().
| bool SCEVAffinator::hasNSWAddRecForLoop | ( | llvm::Loop * | L | ) | const |
Check an <nsw> AddRec for the loop L is cached.
Definition at line 176 of file SCEVAffinator.cpp.
References CachedExpressions.
| void SCEVAffinator::interpretAsUnsigned | ( | PWACtx & | PWAC, |
| unsigned | Width ) |
Interpret the PWA in PWAC as an unsigned value.
Definition at line 90 of file SCEVAffinator.cpp.
References getWidthExpValOnDomain(), isl_pw_aff_add(), isl_pw_aff_intersect_domain(), isl_pw_aff_nonneg_set(), isl_pw_aff_union_add(), isl_set_complement(), isl_set_copy(), and isl::checked::manage().
Referenced by visitZeroExtendExpr().
| void SCEVAffinator::takeNonNegativeAssumption | ( | PWACtx & | PWAC, |
| RecordedAssumptionsTy * | RecordedAssumptions = nullptr ) |
Take the assumption that PWAC is non-negative.
Definition at line 99 of file SCEVAffinator.cpp.
References polly::AS_RESTRICTION, BB, isl_pw_aff_neg(), isl_pw_aff_pos_set(), isl_set_copy(), isl_set_params(), isl_set_union(), isl::checked::manage(), polly::recordAssumption(), RecordedAssumptions, and polly::UNSIGNED.
Referenced by visitUDivExpr(), and visitZeroExtendExpr().
|
private |
Definition at line 199 of file SCEVAffinator.cpp.
References addModuloSemantic(), BB, CachedExpressions, checkForWrapping(), combine(), computeModuloForExpr(), Ctx, Domain, polly::extractConstantFactor(), polly::getParamsInAffineExpr(), getPWACtxFromPWA(), getScope(), isl_aff_add_coefficient_si(), isl_aff_zero_on_domain(), isl_dim_param, isl_local_space_from_space(), isl_pw_aff_alloc(), isl_pw_aff_mul(), isl_set, isl_set_universe(), isl_space_copy(), isl_space_set_alloc(), isl_space_set_dim_id(), isl::checked::manage(), NumIterators, S, SE, and visitConstant().
Referenced by complexityBailout(), getPwAff(), visitAddExpr(), visitAddRecExpr(), visitMulExpr(), visitPtrToAddrExpr(), visitPtrToIntExpr(), visitSDivInstruction(), visitSignExtendExpr(), visitSMaxExpr(), visitSMinExpr(), visitSRemInstruction(), visitTruncateExpr(), visitUDivExpr(), visitUnknown(), and visitZeroExtendExpr().
|
private |
Definition at line 384 of file SCEVAffinator.cpp.
References combine(), complexityBailout(), isl_pw_aff_add(), isTooComplex(), and visit().
|
private |
Definition at line 408 of file SCEVAffinator.cpp.
References assert, combine(), Ctx, isl_aff_set_coefficient_si(), isl_aff_zero_on_domain(), isl_dim_in, isl_local_space_from_space(), isl_pw_aff_add(), isl_pw_aff_from_aff(), isl_space_set_alloc(), isl::checked::manage(), NumIterators, S, SE, and visit().
|
private |
Definition at line 250 of file SCEVAffinator.cpp.
References Ctx, getPWACtxFromPWA(), isl_aff_val_on_domain(), isl_local_space_from_space(), isl_pw_aff_from_aff(), isl_space_set_alloc(), polly::isl_valFromAPInt(), isl::checked::manage(), NumIterators, and polly::Value.
Referenced by visit().
|
private |
Definition at line 396 of file SCEVAffinator.cpp.
References combine(), complexityBailout(), isl_pw_aff_mul(), isTooComplex(), and visit().
|
private |
Definition at line 276 of file SCEVAffinator.cpp.
References visit().
|
private |
Definition at line 280 of file SCEVAffinator.cpp.
References visit().
|
private |
Definition at line 522 of file SCEVAffinator.cpp.
References assert, combine(), getScope(), isl_pw_aff_tdiv_q(), SE, and visit().
Referenced by visitUnknown().
|
private |
Definition at line 480 of file SCEVAffinator.cpp.
|
private |
Definition at line 379 of file SCEVAffinator.cpp.
References visit().
|
private |
Definition at line 447 of file SCEVAffinator.cpp.
References combine(), complexityBailout(), isl_pw_aff_max(), isTooComplex(), and visit().
|
private |
Definition at line 459 of file SCEVAffinator.cpp.
References combine(), complexityBailout(), isl_pw_aff_min(), isTooComplex(), and visit().
|
private |
Definition at line 539 of file SCEVAffinator.cpp.
References assert, combine(), getScope(), isl_pw_aff_tdiv_r(), SE, and visit().
Referenced by visitUnknown().
|
private |
Definition at line 284 of file SCEVAffinator.cpp.
References polly::AS_RESTRICTION, assert, BB, computeModuloForExpr(), getWidthExpValOnDomain(), IsInsideDomain, isl_dim_set, isl_pw_aff_copy(), isl_pw_aff_ge_set(), isl_pw_aff_lt_set(), isl_pw_aff_neg(), isl_set_dim(), isl_set_params(), isl_set_union(), isl::checked::manage(), isl::checked::manage_copy(), polly::recordAssumption(), RecordedAssumptions, TD, polly::UNSIGNED, and visit().
|
private |
Definition at line 484 of file SCEVAffinator.cpp.
References assert, combine(), getWidthExpValOnDomain(), isl_pw_aff_div(), isl::checked::manage(), RecordedAssumptions, SE, takeNonNegativeAssumption(), TD, and visit().
|
private |
Definition at line 471 of file SCEVAffinator.cpp.
|
private |
Definition at line 475 of file SCEVAffinator.cpp.
|
private |
Definition at line 556 of file SCEVAffinator.cpp.
References Ctx, getPWACtxFromPWA(), getScope(), NumIterators, SE, visit(), visitSDivInstruction(), and visitSRemInstruction().
|
private |
Definition at line 272 of file SCEVAffinator.cpp.
|
private |
Definition at line 319 of file SCEVAffinator.cpp.
References computeModuloForExpr(), interpretAsUnsigned(), RecordedAssumptions, takeNonNegativeAssumption(), TD, and visit().
|
friend |
Definition at line 135 of file SCEVAffinator.h.
References SCEVAffinator().
|
private |
Definition at line 77 of file SCEVAffinator.h.
Referenced by checkForWrapping(), complexityBailout(), getPwAff(), getScope(), takeNonNegativeAssumption(), visit(), and visitTruncateExpr().
Map to remembered cached expressions.
Definition at line 70 of file SCEVAffinator.h.
Referenced by hasNSWAddRecForLoop(), and visit().
|
private |
Definition at line 73 of file SCEVAffinator.h.
Referenced by addModuloSemantic(), getPWACtxFromPWA(), SCEVAffinator(), visit(), visitAddRecExpr(), visitConstant(), and visitUnknown().
|
private |
Whether the evaluation takes place only when BB's domain has already been checked.
Definition at line 82 of file SCEVAffinator.h.
Referenced by getPwAff(), and visitTruncateExpr().
|
private |
Definition at line 76 of file SCEVAffinator.h.
Referenced by getLI(), getScope(), and SCEVAffinator().
|
private |
Definition at line 74 of file SCEVAffinator.h.
Referenced by getPWACtxFromPWA(), getPwAff(), visit(), visitAddRecExpr(), visitConstant(), and visitUnknown().
|
private |
Definition at line 84 of file SCEVAffinator.h.
Referenced by checkForWrapping(), getPwAff(), takeNonNegativeAssumption(), visitTruncateExpr(), visitUDivExpr(), and visitZeroExtendExpr().
|
private |
Definition at line 72 of file SCEVAffinator.h.
Referenced by complexityBailout(), getPwAff(), SCEVAffinator(), visit(), and visitAddRecExpr().
|
private |
Definition at line 75 of file SCEVAffinator.h.
Referenced by complexityBailout(), SCEVAffinator(), visit(), visitAddRecExpr(), visitSDivInstruction(), visitSRemInstruction(), visitUDivExpr(), and visitUnknown().
|
private |
Target data for element size computing.
Definition at line 87 of file SCEVAffinator.h.
Referenced by addModuloSemantic(), computeModuloForExpr(), SCEVAffinator(), visitTruncateExpr(), visitUDivExpr(), and visitZeroExtendExpr().