[llvm-commits] [polly] r138219 - in /polly/trunk: include/polly/LinkAllPasses.h include/polly/ScopInfo.h include/polly/TempScopInfo.h lib/Analysis/ScopInfo.cpp lib/Analysis/TempScopInfo.cpp lib/CMakeLists.txt lib/Interchange.cpp test/TempScop/reduction-add.c test/TempScop/reduction-add.ll test/TempScop/reduction-sub.c test/TempScop/reduction-sub.ll test/TempScop/reduction-with-added-immediate.c test/TempScop/reduction-with-added-immediate.ll

Tobias Grosser grosser at fim.uni-passau.de
Sun Aug 21 07:57:58 PDT 2011


Author: grosser
Date: Sun Aug 21 09:57:58 2011
New Revision: 138219

URL: http://llvm.org/viewvc/llvm-project?rev=138219&view=rev
Log:
Temporarily remove reduction support and interchange pass

I am planning to eliminate the TempScopInfo pass. To simplify this I remove
some features that may later be added to the ScopInfo pass.

The interchange pass is currently strongly tested and furthermore ment to be
replaced by the general scheduling optimizer. Reductions itself can later
be added easily.

Removed:
    polly/trunk/lib/Interchange.cpp
    polly/trunk/test/TempScop/reduction-add.c
    polly/trunk/test/TempScop/reduction-add.ll
    polly/trunk/test/TempScop/reduction-sub.c
    polly/trunk/test/TempScop/reduction-sub.ll
    polly/trunk/test/TempScop/reduction-with-added-immediate.c
    polly/trunk/test/TempScop/reduction-with-added-immediate.ll
Modified:
    polly/trunk/include/polly/LinkAllPasses.h
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/include/polly/TempScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/Analysis/TempScopInfo.cpp
    polly/trunk/lib/CMakeLists.txt

Modified: polly/trunk/include/polly/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LinkAllPasses.h?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/include/polly/LinkAllPasses.h (original)
+++ polly/trunk/include/polly/LinkAllPasses.h Sun Aug 21 09:57:58 2011
@@ -38,7 +38,6 @@
   Pass *createDOTPrinterPass();
   Pass *createDOTViewerPass();
   Pass *createIndependentBlocksPass();
-  Pass *createInterchangePass();
   Pass *createJSONExporterPass();
   Pass *createJSONImporterPass();
   Pass *createRegionSimplifyPass();
@@ -83,7 +82,6 @@
        createDOTPrinterPass();
        createDOTViewerPass();
        createIndependentBlocksPass();
-       createInterchangePass();
        createJSONExporterPass();
        createJSONImporterPass();
        createRegionSimplifyPass();

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sun Aug 21 09:57:58 2011
@@ -246,9 +246,6 @@
   /// The BasicBlock represented by this statement.
   BasicBlock *BB;
 
-  /// @brief Whether this statement is a reduction.
-  bool IsReduction;
-
   /// @brief The loop induction variables surrounding the statement.
   ///
   /// This information is only needed for final code generation.
@@ -345,8 +342,6 @@
   /// that all data used in the Scop is read after the Scop.
   bool isFinalRead() { return getBasicBlock() == NULL; }
 
-  bool isReduction() { return IsReduction; }
-
   /// @brief Print the ScopStmt.
   ///
   /// @param OS The output stream the ScopStmt is printed to.

Modified: polly/trunk/include/polly/TempScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/TempScopInfo.h?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/include/polly/TempScopInfo.h (original)
+++ polly/trunk/include/polly/TempScopInfo.h Sun Aug 21 09:57:58 2011
@@ -200,9 +200,6 @@
   // The alias information about this SCoP.
   MayAliasSetInfo *MayASInfo;
 
-  // Basic blocks detected as reductions
-  std::set<BasicBlock*> Reductions;
-
   friend class TempScopInfo;
 
   explicit TempScop(Region &r, LoopBoundMapType &loopBounds,
@@ -213,8 +210,6 @@
 public:
   ~TempScop();
 
-  bool is_Reduction(BasicBlock &BB) { return Reductions.count(&BB) != 0; }
-
   /// @name Information about this Temporary Scop.
   ///
   //@{

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sun Aug 21 09:57:58 2011
@@ -711,8 +711,6 @@
   buildIterationDomain(tempScop, CurRegion);
   buildScattering(Scatter);
   buildAccesses(tempScop, CurRegion);
-
-  IsReduction = tempScop.is_Reduction(*BB);
 }
 
 ScopStmt::ScopStmt(Scop &parent, SmallVectorImpl<unsigned> &Scatter)
@@ -767,8 +765,6 @@
   for (SetVector<const Value*>::iterator BI = BaseAddressSet.begin(),
        BE = BaseAddressSet.end(); BI != BE; ++BI)
     MemAccs.push_back(new MemoryAccess(*BI, this));
-
-  IsReduction = false;
 }
 
 std::string ScopStmt::getDomainStr() const {

Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Sun Aug 21 09:57:58 2011
@@ -186,13 +186,10 @@
             MI->second->print(OS);
             OS << ", ";
           }
-          
+
           OS << '\n';
         }
 
-        if (Reductions.count(BB))
-          OS.indent(ind + 2) << "Reduction\n";
-
         OS.indent(ind) << "}\n";
       }
     }
@@ -234,68 +231,6 @@
   }
 }
 
-bool TempScopInfo::isReduction(BasicBlock &BB) {
-  int loadAccess = 0, storeAccess = 0;
-  const StoreInst *storeInst;
-  const Value *storePointer;
-  const LoadInst *loadInst[2];
-  const Value *loadPointer[2];
-
-  for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) {
-    Instruction &Inst = *I;
-    if (isa<LoadInst>(&Inst)) {
-      if (loadAccess >= 2)
-        return false;
-      loadInst[loadAccess] = dyn_cast<LoadInst>(&Inst);
-      loadPointer[loadAccess] = loadInst[loadAccess]->getPointerOperand();
-      loadAccess++;
-    } else if (isa<StoreInst>(&Inst)) {
-      if (storeAccess >= 1)
-        return false;
-      storeInst = dyn_cast<StoreInst>(&Inst);
-      storePointer = storeInst->getPointerOperand();
-      storeAccess++;
-    }
-  }
-
-  if (loadAccess < 2)
-    return false;
-
-  if (loadPointer[0] == loadPointer[1])
-   return false;
-
-  const Value *reductionLoadInst;
-  if (storePointer == loadPointer[0])
-    reductionLoadInst = loadInst[0];
-  else if (storePointer == loadPointer[1])
-    reductionLoadInst = loadInst[1];
-  else
-    return false;
-
-  const Instruction *reductionInst =
-    dyn_cast<Instruction>(storeInst->getValueOperand());
-
-  // Check if the value stored is an instruction
-  if (!reductionInst)
-    return false;
-
-  // Reduction operations must be associative and commutative
-  if (!reductionInst->isAssociative() || !reductionInst->isCommutative())
-    return false;
-
-  // Check if this instruction is using the loaded value
-  for (User::const_op_iterator I = reductionInst->op_begin(),
-       E = reductionInst->op_end(); I != E; I++) {
-    const Value *operand = I->get();
-    if (operand == reductionLoadInst) {
-      // The loaded value's one and only use must be this one.
-      return operand->hasOneUse();
-    }
-  }
-
-  return false;
-}
-
 void TempScopInfo::buildAccessFunctions(Region &R, ParamSetType &Parameter,
                                         BasicBlock &BB) {
   AccFuncSetType Functions;
@@ -457,8 +392,6 @@
     BasicBlock *BB =  I->getNodeAs<BasicBlock>();
     buildAccessFunctions(R, TScop->getParamSet(), *BB);
     buildCondition(BB, R.getEntry(), *TScop);
-    if (isReduction(*BB))
-      TScop->Reductions.insert(BB);
   }
 
   buildLoopBounds(*TScop);

Modified: polly/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CMakeLists.txt?rev=138219&r1=138218&r2=138219&view=diff
==============================================================================
--- polly/trunk/lib/CMakeLists.txt (original)
+++ polly/trunk/lib/CMakeLists.txt Sun Aug 21 09:57:58 2011
@@ -28,7 +28,6 @@
   CodePreparation.cpp
   CodeGeneration.cpp
   IndependentBlocks.cpp
-  Interchange.cpp
   MayAliasSet.cpp
   Pocc.cpp
   RegionSimplify.cpp

Removed: polly/trunk/lib/Interchange.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Interchange.cpp?rev=138218&view=auto
==============================================================================
--- polly/trunk/lib/Interchange.cpp (original)
+++ polly/trunk/lib/Interchange.cpp (removed)
@@ -1,83 +0,0 @@
-//===- Interchange.cpp - Interchange interface ----------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "polly/Cloog.h"
-#include "polly/LinkAllPasses.h"
-
-#include "polly/ScopInfo.h"
-#include "polly/Dependences.h"
-
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Program.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/CommandLine.h"
-
-#include <isl/map.h>
-
-#define DEBUG_TYPE "polly-interchange"
-#include "llvm/Support/Debug.h"
-
-using namespace llvm;
-using namespace polly;
-
-namespace {
-
-  class Interchange : public ScopPass {
-  public:
-    static char ID;
-    explicit Interchange() : ScopPass(ID) {}
-
-    virtual bool runOnScop(Scop &S);
-    void getAnalysisUsage(AnalysisUsage &AU) const;
-  };
-
-}
-
-char Interchange::ID = 0;
-bool Interchange::runOnScop(Scop &S) {
-  if (std::distance(S.begin(), S.end()) != 2) // One statement besides the final statement
-    return false;
-
-  for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
-    ScopStmt *Stmt = *SI;
-    if (!Stmt->isReduction())
-      continue;
-
-    isl_map *Scattering = isl_map_copy(Stmt->getScattering());
-
-    const std::string MapString = "{scattering[i0, i1, i2, i3, i4] -> scattering[i0, i3, i2, i1, i4]}";
-    isl_map *Map = isl_map_read_from_str(Stmt->getIslContext(), MapString.c_str(), -1);
-
-    isl_map_add_dims(Map, isl_dim_param, Stmt->getNumParams());
-    Scattering = isl_map_apply_range(Scattering, Map);
-    Stmt->setScattering(Scattering);
-
-    DEBUG(
-      isl_printer *p = isl_printer_to_str(S.getCtx());
-      isl_printer_print_map(p, Scattering);
-      dbgs() << isl_printer_get_str(p) << '\n';
-      isl_printer_flush(p);
-      isl_printer_free(p);
-    );
-  }
-
-  return false;
-}
-
-void Interchange::getAnalysisUsage(AnalysisUsage &AU) const {
-  ScopPass::getAnalysisUsage(AU);
-  AU.addRequired<Dependences>();
-}
-
-static RegisterPass<Interchange> A("polly-interchange",
-                            "Polly - Perform loop interchange");
-
-Pass* polly::createInterchangePass() {
-  return new Interchange();
-}

Removed: polly/trunk/test/TempScop/reduction-add.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-add.c?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-add.c (original)
+++ polly/trunk/test/TempScop/reduction-add.c (removed)
@@ -1,12 +0,0 @@
-#define NUM 128
-
-int A[NUM];
-int R;
-
-int reduction(void) {
-	int i;
-	for (i = 0; i < NUM; i++) {
-		R += A[i];
-	}
-	return R;
-}

Removed: polly/trunk/test/TempScop/reduction-add.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-add.ll?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-add.ll (original)
+++ polly/trunk/test/TempScop/reduction-add.ll (removed)
@@ -1,35 +0,0 @@
-; RUN: opt %loadPolly %defaultOpts -polly-analyze-ir -analyze < %s 2>&1 | FileCheck %s
-; ModuleID = 'reduction-add.s'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
-target triple = "x86_64-pc-linux-gnu"
-
- at A = common global [128 x i32] zeroinitializer, align 16
- at R = common global i32 0, align 4
-
-define i32 @reduction() nounwind {
-bb:
-  br label %bb1
-
-bb1:                                              ; preds = %bb5, %bb
-  %indvar = phi i64 [ %indvar.next, %bb5 ], [ 0, %bb ]
-  %scevgep = getelementptr [128 x i32]* @A, i64 0, i64 %indvar
-  %exitcond = icmp ne i64 %indvar, 128
-  br i1 %exitcond, label %bb2, label %bb6
-
-bb2:                                              ; preds = %bb1
-  %tmp = load i32* %scevgep, align 4
-  %tmp3 = load i32* @R, align 4
-  %tmp4 = add nsw i32 %tmp3, %tmp
-  store i32 %tmp4, i32* @R, align 4
-  br label %bb5
-
-bb5:                                              ; preds = %bb2
-  %indvar.next = add i64 %indvar, 1
-  br label %bb1
-
-bb6:                                              ; preds = %bb1
-  %tmp7 = load i32* @R, align 4
-  ret i32 %tmp7
-}
-
-; CHECK:     Reduction

Removed: polly/trunk/test/TempScop/reduction-sub.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-sub.c?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-sub.c (original)
+++ polly/trunk/test/TempScop/reduction-sub.c (removed)
@@ -1,12 +0,0 @@
-#define NUM 128
-
-int A[NUM];
-int R;
-
-int reduction(void) {
-	int i;
-	for (i = 0; i < NUM; i++) {
-		R -= A[i];
-	}
-	return R;
-}

Removed: polly/trunk/test/TempScop/reduction-sub.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-sub.ll?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-sub.ll (original)
+++ polly/trunk/test/TempScop/reduction-sub.ll (removed)
@@ -1,35 +0,0 @@
-; RUN: opt -polly-analyze-ir -analyze < %s 2>&1 | not FileCheck %s
-; ModuleID = 'reduction-sub.s'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
-target triple = "x86_64-pc-linux-gnu"
-
- at A = common global [128 x i32] zeroinitializer, align 16
- at R = common global i32 0, align 4
-
-define i32 @reduction() nounwind {
-bb:
-  br label %bb1
-
-bb1:                                              ; preds = %bb5, %bb
-  %indvar = phi i64 [ %indvar.next, %bb5 ], [ 0, %bb ]
-  %scevgep = getelementptr [128 x i32]* @A, i64 0, i64 %indvar
-  %exitcond = icmp ne i64 %indvar, 128
-  br i1 %exitcond, label %bb2, label %bb6
-
-bb2:                                              ; preds = %bb1
-  %tmp = load i32* %scevgep, align 4
-  %tmp3 = load i32* @R, align 4
-  %tmp4 = sub nsw i32 %tmp3, %tmp
-  store i32 %tmp4, i32* @R, align 4
-  br label %bb5
-
-bb5:                                              ; preds = %bb2
-  %indvar.next = add i64 %indvar, 1
-  br label %bb1
-
-bb6:                                              ; preds = %bb1
-  %tmp7 = load i32* @R, align 4
-  ret i32 %tmp7
-}
-
-; CHECK:     Reduction

Removed: polly/trunk/test/TempScop/reduction-with-added-immediate.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-with-added-immediate.c?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-with-added-immediate.c (original)
+++ polly/trunk/test/TempScop/reduction-with-added-immediate.c (removed)
@@ -1,12 +0,0 @@
-#define NUM 128
-
-int A[NUM];
-int R;
-
-int not_a_reduction(void) {
-	int i;
-	for (i = 0; i < NUM; i++) {
-		R += 1 + A[i];
-	}
-	return R;
-}

Removed: polly/trunk/test/TempScop/reduction-with-added-immediate.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/TempScop/reduction-with-added-immediate.ll?rev=138218&view=auto
==============================================================================
--- polly/trunk/test/TempScop/reduction-with-added-immediate.ll (original)
+++ polly/trunk/test/TempScop/reduction-with-added-immediate.ll (removed)
@@ -1,36 +0,0 @@
-; RUN: opt %loadPolly %defaultOpts -polly-analyze-ir -analyze < %s 2>&1 | FileCheck %s
-; ModuleID = 'reduction-with-added-immediate.s'
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
-target triple = "x86_64-pc-linux-gnu"
-
- at A = common global [128 x i32] zeroinitializer, align 16
- at R = common global i32 0, align 4
-
-define i32 @not_a_reduction() nounwind {
-bb:
-  br label %bb1
-
-bb1:                                              ; preds = %bb6, %bb
-  %indvar = phi i64 [ %indvar.next, %bb6 ], [ 0, %bb ]
-  %scevgep = getelementptr [128 x i32]* @A, i64 0, i64 %indvar
-  %exitcond = icmp ne i64 %indvar, 128
-  br i1 %exitcond, label %bb2, label %bb7
-
-bb2:                                              ; preds = %bb1
-  %tmp = load i32* %scevgep, align 4
-  %tmp3 = add nsw i32 %tmp, 1
-  %tmp4 = load i32* @R, align 4
-  %tmp5 = add nsw i32 %tmp4, %tmp3
-  store i32 %tmp5, i32* @R, align 4
-  br label %bb6
-
-bb6:                                              ; preds = %bb2
-  %indvar.next = add i64 %indvar, 1
-  br label %bb1
-
-bb7:                                              ; preds = %bb1
-  %tmp8 = load i32* @R, align 4
-  ret i32 %tmp8
-}
-
-; CHECK:     Reduction





More information about the llvm-commits mailing list