[llvm-commits] [polly] r144280 - in /polly/trunk: include/polly/Support/SCEVValidator.h lib/Analysis/ScopDetection.cpp lib/Analysis/ScopInfo.cpp lib/Analysis/TempScopInfo.cpp lib/Support/SCEVValidator.cpp

Tobias Grosser grosser at fim.uni-passau.de
Thu Nov 10 04:45:03 PST 2011


Author: grosser
Date: Thu Nov 10 06:45:03 2011
New Revision: 144280

URL: http://llvm.org/viewvc/llvm-project?rev=144280&view=rev
Log:
Reuse the old BaseAddress checking in SCEVValidator to make sure that no base
address is part of the access function. Also remove unused special cases that
were necessery when the base address was still contained in the access function

Modified:
    polly/trunk/include/polly/Support/SCEVValidator.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/Analysis/TempScopInfo.cpp
    polly/trunk/lib/Support/SCEVValidator.cpp

Modified: polly/trunk/include/polly/Support/SCEVValidator.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/SCEVValidator.h?rev=144280&r1=144279&r2=144280&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/SCEVValidator.h (original)
+++ polly/trunk/include/polly/Support/SCEVValidator.h Thu Nov 10 06:45:03 2011
@@ -23,12 +23,13 @@
 
 namespace polly {
   bool isAffineExpr(const llvm::Region *R, const llvm::SCEV *Expression,
-                    llvm::ScalarEvolution &SE, llvm::Value **BaseAddress = 0);
+                    llvm::ScalarEvolution &SE,
+                    const llvm::Value *BaseAddress = 0);
   std::vector<const llvm::SCEV*> getParamsInAffineExpr(
     const llvm::Region *R,
     const llvm::SCEV *Expression,
     llvm::ScalarEvolution &SE,
-    llvm::Value **BaseAddress = 0);
+    const llvm::Value *BaseAddress = 0);
 
 }
 

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=144280&r1=144279&r2=144280&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu Nov 10 06:45:03 2011
@@ -212,10 +212,10 @@
 
 bool ScopDetection::isValidMemoryAccess(Instruction &Inst,
                                         DetectionContext &Context) const {
-  Value *Ptr = getPointerOperand(Inst), *BasePtr;
+  Value *Ptr = getPointerOperand(Inst);
   const SCEV *AccessFunction = SE->getSCEV(Ptr);
   const SCEVUnknown *BasePointer;
-  const Value *BaseValue;
+  Value *BaseValue;
 
   BasePointer = dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
 
@@ -229,23 +229,21 @@
 
   AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
 
-  if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE))
+  if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue))
     INVALID(AffFunc, "Bad memory address " << *AccessFunction);
 
-  BasePtr = BasePointer->getValue();
-
   // FIXME: Alias Analysis thinks IntToPtrInst aliases with alloca instructions
   // created by IndependentBlocks Pass.
-  if (isa<IntToPtrInst>(BasePtr))
-    INVALID(Other, "Find bad intToptr prt: " << *BasePtr);
+  if (isa<IntToPtrInst>(BaseValue))
+    INVALID(Other, "Find bad intToptr prt: " << *BaseValue);
 
   // Check if the base pointer of the memory access does alias with
   // any other pointer. This cannot be handled at the moment.
   AliasSet &AS =
-    Context.AST.getAliasSetForPointer(BasePtr, AliasAnalysis::UnknownSize,
+    Context.AST.getAliasSetForPointer(BaseValue, AliasAnalysis::UnknownSize,
                                       Inst.getMetadata(LLVMContext::MD_tbaa));
   if (!AS.isMustAlias()) {
-    DEBUG(dbgs() << "Bad pointer alias found:" << *BasePtr << "\nAS:\n" << AS);
+    DEBUG(dbgs() << "Bad pointer alias found:" << *BaseValue << "\nAS:\n" << AS);
 
     // STATSCOP triggers an assertion if we are in verifying mode.
     // This is generally good to check that we do not change the SCoP after we

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=144280&r1=144279&r2=144280&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Nov 10 06:45:03 2011
@@ -76,24 +76,14 @@
   int NbLoopSpaces;
   const Scop *scop;
 
-  /// baseAdress is set if we analyze a memory access. It holds the base address
-  /// of this memory access.
-  const Value *baseAddress;
-
 public:
-  static isl_pw_aff *getPwAff(ScopStmt *stmt, const SCEV *scev,
-                              Value **BaseAddress = NULL) {
+  static isl_pw_aff *getPwAff(ScopStmt *stmt, const SCEV *scev) {
     Scop *S = stmt->getParent();
     const Region *Reg = &S->getRegion();
 
-    if (BaseAddress) {
-      S->addParams(getParamsInAffineExpr(Reg, scev, *S->getSE(), BaseAddress));
-    } else {
-      S->addParams(getParamsInAffineExpr(Reg, scev, *S->getSE()));
-    }
+    S->addParams(getParamsInAffineExpr(Reg, scev, *S->getSE()));
 
-    Value *Base = BaseAddress ? *BaseAddress : NULL;
-    SCEVAffinator Affinator(stmt, Base);
+    SCEVAffinator Affinator(stmt);
     return Affinator.visit(scev);
   }
 
@@ -117,11 +107,10 @@
     return SCEVVisitor<SCEVAffinator, isl_pw_aff*>::visit(scev);
   }
 
-  SCEVAffinator(const ScopStmt *stmt, const Value *baseAddress) :
+  SCEVAffinator(const ScopStmt *stmt) :
     ctx(stmt->getIslCtx()),
     NbLoopSpaces(stmt->getNumIterators()),
-    scop(stmt->getParent()),
-    baseAddress(baseAddress) {};
+    scop(stmt->getParent()) {}
 
   __isl_give isl_pw_aff *visitConstant(const SCEVConstant *Constant) {
     ConstantInt *Value = Constant->getValue();
@@ -248,22 +237,14 @@
 
     isl_space *Space;
 
-    /// If baseAddress is set, we ignore its Value object in the scev and do not
-    /// add it to the isl_pw_aff. This is because it is regarded as defining the
-    /// name of an array, in contrast to its array subscript.
-    if (baseAddress != Value) {
-      isl_id *ID = isl_id_alloc(ctx, Value->getNameStr().c_str(), Value);
-      Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces);
-      Space = isl_space_set_dim_id(Space, isl_dim_param, 0, ID);
-    } else {
-      Space = isl_space_set_alloc(ctx, 0, NbLoopSpaces);
-    }
+    isl_id *ID = isl_id_alloc(ctx, Value->getNameStr().c_str(), Value);
+    Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces);
+    Space = isl_space_set_dim_id(Space, isl_dim_param, 0, ID);
 
     isl_set *Domain = isl_set_universe(isl_space_copy(Space));
     isl_aff *Affine = isl_aff_zero_on_domain(isl_local_space_from_space(Space));
 
-    if (baseAddress != Value)
-      Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1);
+    Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1);
 
     return isl_pw_aff_alloc(Domain, Affine);
   }

Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=144280&r1=144279&r2=144280&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Thu Nov 10 06:45:03 2011
@@ -95,7 +95,9 @@
 
       const SCEV *AccessFunction = SE->getSCEV(getPointerOperand(Inst));
       const SCEVUnknown *BasePointer =
-        static_cast<const SCEVUnknown*>(SE->getPointerBase(AccessFunction));
+        dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
+
+      assert(BasePointer && "Could not find base pointer");
 
       AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
       Functions.push_back(std::make_pair(IRAccess(Type,

Modified: polly/trunk/lib/Support/SCEVValidator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVValidator.cpp?rev=144280&r1=144279&r2=144280&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVValidator.cpp (original)
+++ polly/trunk/lib/Support/SCEVValidator.cpp Thu Nov 10 06:45:03 2011
@@ -57,11 +57,11 @@
 private:
   const Region *R;
   ScalarEvolution &SE;
-  Value **BaseAddress;
+  const Value *BaseAddress;
 
 public:
   SCEVValidator(const Region *R, ScalarEvolution &SE,
-                Value **BaseAddress) : R(R), SE(SE),
+                const Value *BaseAddress) : R(R), SE(SE),
     BaseAddress(BaseAddress) {};
 
   struct ValidatorResult visitConstant(const SCEVConstant *Constant) {
@@ -215,33 +215,23 @@
     if (isa<UndefValue>(V))
       return ValidatorResult(SCEVType::INVALID);
 
-    if (BaseAddress) {
-      if (*BaseAddress)
-        return ValidatorResult(SCEVType::INVALID);
-      else
-        *BaseAddress = V;
-    }
-
     if (Instruction *I = dyn_cast<Instruction>(Expr->getValue()))
       if (R->contains(I))
         return ValidatorResult(SCEVType::INVALID);
 
-    if (BaseAddress)
-      return ValidatorResult(SCEVType::PARAM);
-    else
-      return ValidatorResult(SCEVType::PARAM, Expr);
+    if (BaseAddress == V)
+      return ValidatorResult(SCEVType::INVALID);
+
+    return ValidatorResult(SCEVType::PARAM, Expr);
   }
 };
 
 namespace polly {
   bool isAffineExpr(const Region *R, const SCEV *Expr, ScalarEvolution &SE,
-                    Value **BaseAddress) {
+                    const Value *BaseAddress) {
     if (isa<SCEVCouldNotCompute>(Expr))
       return false;
 
-    if (BaseAddress)
-      *BaseAddress = NULL;
-
     SCEVValidator Validator(R, SE, BaseAddress);
     ValidatorResult Result = Validator.visit(Expr);
 
@@ -251,13 +241,10 @@
   std::vector<const SCEV*> getParamsInAffineExpr(const Region *R,
                                                  const SCEV *Expr,
                                                  ScalarEvolution &SE,
-                                                 Value **BaseAddress) {
+                                                 const Value *BaseAddress) {
     if (isa<SCEVCouldNotCompute>(Expr))
       return std::vector<const SCEV*>();
 
-    if (BaseAddress)
-      *BaseAddress = NULL;
-
     SCEVValidator Validator(R, SE, BaseAddress);
     ValidatorResult Result = Validator.visit(Expr);
 





More information about the llvm-commits mailing list