[llvm-commits] [polly] r144228 - in /polly/trunk: include/polly/ScopDetection.h lib/Analysis/ScopDetection.cpp

Tobias Grosser grosser at fim.uni-passau.de
Wed Nov 9 14:34:53 PST 2011


Author: grosser
Date: Wed Nov  9 16:34:53 2011
New Revision: 144228

URL: http://llvm.org/viewvc/llvm-project?rev=144228&view=rev
Log:
Do not check memory accesses additionally with isValidAffineFunction

This check was necessary because of the use AffineSCEVIterator in TempScopInfo.
As we removed this use recently it is not necessary any more.

Modified:
    polly/trunk/include/polly/ScopDetection.h
    polly/trunk/lib/Analysis/ScopDetection.cpp

Modified: polly/trunk/include/polly/ScopDetection.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=144228&r1=144227&r2=144228&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetection.h (original)
+++ polly/trunk/include/polly/ScopDetection.h Wed Nov  9 16:34:53 2011
@@ -187,20 +187,6 @@
   /// @return True if the BB contains only valid control flow.
   bool isValidCFG(BasicBlock &BB, DetectionContext &Context) const;
 
-  /// @brief Check if the SCEV expression is a valid affine function
-  ///
-  /// @param S          The SCEV expression to be checked
-  /// @param RefRegion  The reference scope to check SCEV, it help to find out
-  ///                   induction variables and parameters
-  /// @param BasePtr    If S represents a memory access, BasePtr should contain
-  ///                   a valid memory location to which the base address of the
-  ///                   memory access will be stored.
-  ///
-  /// @return True if the SCEV expression is affine, false otherwise
-  ///
-  bool isValidAffineFunction(const SCEV *S, Region &RefRegion,
-                             Value **BasePtr = 0) const;
-
   /// @brief Is a loop valid with respect to a given region.
   ///
   /// @param L The loop to check.

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=144228&r1=144227&r2=144228&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Wed Nov  9 16:34:53 2011
@@ -123,74 +123,6 @@
   return InvalidRegions.find(R)->second;
 }
 
-
-bool ScopDetection::isValidAffineFunction(const SCEV *S, Region &RefRegion,
-                                          Value **BasePtr) const {
-  assert(S && "S must not be null!");
-  bool isMemoryAccess = (BasePtr != 0);
-  if (isMemoryAccess) *BasePtr = 0;
-  DEBUG(dbgs() << "Checking " << *S << " ... ");
-
-  if (isa<SCEVCouldNotCompute>(S)) {
-    DEBUG(dbgs() << "Non Affine: SCEV could not be computed\n");
-    return false;
-  }
-
-  for (AffineSCEVIterator I = affine_begin(S, SE), E = affine_end(); I != E;
-       ++I) {
-    // The constant part must be a SCEVConstant.
-    // TODO: support sizeof in coefficient.
-    if (!isa<SCEVConstant>(I->second)) {
-      DEBUG(dbgs() << "Non Affine: Right hand side is not constant\n");
-      return false;
-    }
-
-    const SCEV *Var = I->first;
-
-    // A constant offset is affine.
-    if(isa<SCEVConstant>(Var))
-      continue;
-
-    // Memory accesses are allowed to have a base pointer.
-    if (Var->getType()->isPointerTy()) {
-      if (!isMemoryAccess) {
-        DEBUG(dbgs() << "Non Affine: Pointer in non memory access\n");
-        return false;
-      }
-
-      assert(I->second->isOne() && "Only one as pointer coefficient allowed.\n");
-      const SCEVUnknown *BaseAddr = dyn_cast<SCEVUnknown>(Var);
-
-      if (!BaseAddr || isa<UndefValue>(BaseAddr->getValue())){
-        DEBUG(dbgs() << "Cannot handle base: " << *Var << "\n");
-        return false;
-      }
-
-      // BaseAddr must be invariant in Scop.
-      if (!isParameter(BaseAddr, RefRegion, *LI, *SE)) {
-        DEBUG(dbgs() << "Non Affine: Base address not invariant in SCoP\n");
-        return false;
-      }
-
-      assert(*BasePtr == 0 && "Found second base pointer.\n");
-      *BasePtr = BaseAddr->getValue();
-      continue;
-    }
-
-    if (isParameter(Var, RefRegion, *LI, *SE)
-        || isIndVar(Var, RefRegion, *LI, *SE))
-      continue;
-
-    DEBUG(dbgs() << "Non Affine: " ;
-          Var->print(dbgs());
-          dbgs() << " is neither parameter nor induction variable\n");
-    return false;
-  }
-
-  DEBUG(dbgs() << " is affine.\n");
-  return !isMemoryAccess || (*BasePtr != 0);
-}
-
 bool ScopDetection::isValidCFG(BasicBlock &BB, DetectionContext &Context) const
 {
   Region &RefRegion = Context.CurRegion;
@@ -284,12 +216,6 @@
   if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, &BasePtr))
     INVALID(AffFunc, "Bad memory address " << *AccessFunction);
 
-  // FIXME: Also check with isValidAffineFunction, as for the moment it is
-  //        protecting us to fail because of not supported features in TempScop.
-  //        As soon as TempScop is fixed, this needs to be removed.
-  if (!isValidAffineFunction(AccessFunction, Context.CurRegion, &BasePtr))
-    INVALID(AffFunc, "Access not supported in TempScop" << *AccessFunction);
-
   // FIXME: Alias Analysis thinks IntToPtrInst aliases with alloca instructions
   // created by IndependentBlocks Pass.
   if (isa<IntToPtrInst>(BasePtr))





More information about the llvm-commits mailing list