[polly] r269044 - Expose interpretAsUnsigned in the SCEVAffinator [NFC]
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue May 10 04:45:46 PDT 2016
Author: jdoerfert
Date: Tue May 10 06:45:46 2016
New Revision: 269044
URL: http://llvm.org/viewvc/llvm-project?rev=269044&view=rev
Log:
Expose interpretAsUnsigned in the SCEVAffinator [NFC]
This exposes the functionality to interpret a SCEV, or better the
piece-wise function created from the SCEV, as an unsigned value
instead of a signed one.
Modified:
polly/trunk/include/polly/Support/SCEVAffinator.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Support/SCEVAffinator.cpp
Modified: polly/trunk/include/polly/Support/SCEVAffinator.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/SCEVAffinator.h?rev=269044&r1=269043&r2=269044&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/SCEVAffinator.h (original)
+++ polly/trunk/include/polly/Support/SCEVAffinator.h Tue May 10 06:45:46 2016
@@ -67,6 +67,9 @@ public:
/// @brief Take the asumption that @p PWAC is non-negative.
void takeNonNegativeAssumption(PWACtx &PWAC);
+ /// @brief Interpret the PWA in @p PWAC as an unsigned value.
+ void interpretAsUnsigned(__isl_keep PWACtx &PWAC, unsigned Width);
+
/// @brief Check an <nsw> AddRec for the loop @p L is cached.
bool hasNSWAddRecForLoop(llvm::Loop *L) const;
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=269044&r1=269043&r2=269044&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue May 10 06:45:46 2016
@@ -3797,6 +3797,11 @@ __isl_give PWACtx Scop::getPwAff(const S
// handling cdoe to all users of this function.
auto PWAC = Affinator.getPwAff(E, BB);
if (PWAC.first) {
+ // TODO: We could use a heuristic and either use:
+ // SCEVAffinator::takeNonNegativeAssumption
+ // or
+ // SCEVAffinator::interpretAsUnsigned
+ // to deal with unsigned or "NonNegative" SCEVs.
if (NonNegative)
Affinator.takeNonNegativeAssumption(PWAC);
return PWAC;
Modified: polly/trunk/lib/Support/SCEVAffinator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVAffinator.cpp?rev=269044&r1=269043&r2=269044&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVAffinator.cpp (original)
+++ polly/trunk/lib/Support/SCEVAffinator.cpp Tue May 10 06:45:46 2016
@@ -127,6 +127,16 @@ SCEVAffinator::~SCEVAffinator() {
freePWACtx(CachedPair.second);
}
+void SCEVAffinator::interpretAsUnsigned(__isl_keep PWACtx &PWAC,
+ unsigned Width) {
+ auto *PWA = PWAC.first;
+ auto *NonNegDom = isl_pw_aff_nonneg_set(isl_pw_aff_copy(PWA));
+ auto *NonNegPWA = isl_pw_aff_intersect_domain(isl_pw_aff_copy(PWA),
+ isl_set_copy(NonNegDom));
+ auto *ExpPWA = getWidthExpValOnDomain(Width, isl_set_complement(NonNegDom));
+ PWAC.first = isl_pw_aff_union_add(NonNegPWA, isl_pw_aff_add(PWA, ExpPWA));
+}
+
void SCEVAffinator::takeNonNegativeAssumption(PWACtx &PWAC) {
auto *NegPWA = isl_pw_aff_neg(isl_pw_aff_copy(PWAC.first));
auto *NegDom = isl_pw_aff_pos_set(NegPWA);
@@ -353,12 +363,7 @@ SCEVAffinator::visitZeroExtendExpr(const
// If the width is small build the piece for the non-negative part and
// the one for the negative part and unify them.
- auto *NonNegDom = isl_pw_aff_nonneg_set(isl_pw_aff_copy(OpPWAC.first));
- auto *NonNegPWA = isl_pw_aff_intersect_domain(isl_pw_aff_copy(OpPWAC.first),
- isl_set_copy(NonNegDom));
- auto *ExpPWA = getWidthExpValOnDomain(Width, isl_set_complement(NonNegDom));
- OpPWAC.first = isl_pw_aff_add(OpPWAC.first, ExpPWA);
- OpPWAC.first = isl_pw_aff_union_add(NonNegPWA, OpPWAC.first);
+ interpretAsUnsigned(OpPWAC, Width);
return OpPWAC;
}
More information about the llvm-commits
mailing list