Expand Up
@@ -27,25 +27,44 @@ using namespace polly;
namespace {
#define TWO_STATISTICS (VARNAME, DESC ) \
static llvm::Statistic VARNAME[2 ] = { \
{DEBUG_TYPE, #VARNAME " 0" , DESC " (first)" , {0 }, false }, \
{DEBUG_TYPE, #VARNAME " 1" , DESC " (second)" , {0 }, false }}
// / Number of max disjuncts we allow in removeOverwrites(). This is to avoid
// / that the analysis of accesses in a statement is becoming too complex. Chosen
// / to be relatively small because all the common cases should access only few
// / array elements per statement.
static int const SimplifyMaxDisjuncts = 4 ;
STATISTIC (ScopsProcessed, " Number of SCoPs processed" );
STATISTIC (ScopsModified, " Number of SCoPs simplified" );
STATISTIC (TotalOverwritesRemoved, " Number of removed overwritten writes" );
STATISTIC (TotalWritesCoalesced, " Number of writes coalesced with another" );
STATISTIC (TotalRedundantWritesRemoved,
" Number of writes of same value removed in any SCoP" );
STATISTIC (TotalEmptyPartialAccessesRemoved,
" Number of empty partial accesses removed" );
STATISTIC (TotalDeadAccessesRemoved, " Number of dead accesses removed" );
STATISTIC (TotalDeadInstructionsRemoved,
" Number of unused instructions removed" );
STATISTIC (TotalStmtsRemoved, " Number of statements removed in any SCoP" );
TWO_STATISTICS (ScopsProcessed, " Number of SCoPs processed" );
TWO_STATISTICS (ScopsModified, " Number of SCoPs simplified" );
TWO_STATISTICS (TotalOverwritesRemoved, " Number of removed overwritten writes" );
TWO_STATISTICS (TotalWritesCoalesced, " Number of writes coalesced with another" );
TWO_STATISTICS (TotalRedundantWritesRemoved,
" Number of writes of same value removed in any SCoP" );
TWO_STATISTICS (TotalEmptyPartialAccessesRemoved,
" Number of empty partial accesses removed" );
TWO_STATISTICS (TotalDeadAccessesRemoved, " Number of dead accesses removed" );
TWO_STATISTICS (TotalDeadInstructionsRemoved,
" Number of unused instructions removed" );
TWO_STATISTICS (TotalStmtsRemoved, " Number of statements removed in any SCoP" );
TWO_STATISTICS (NumValueWrites, " Number of scalar value writes after Simplify" );
TWO_STATISTICS (
NumValueWritesInLoops,
" Number of scalar value writes nested in affine loops after Simplify" );
TWO_STATISTICS (NumPHIWrites,
" Number of scalar phi writes after the first simplification" );
TWO_STATISTICS (
NumPHIWritesInLoops,
" Number of scalar phi writes nested in affine loops after Simplify" );
TWO_STATISTICS (NumSingletonWrites, " Number of singleton writes after Simplify" );
TWO_STATISTICS (
NumSingletonWritesInLoops,
" Number of singleton writes nested in affine loops after Simplify" );
static bool isImplicitRead (MemoryAccess *MA) {
return MA->isRead () && MA->isOriginalScalarKind ();
Expand Down
Expand Up
@@ -100,6 +119,10 @@ static isl::union_map underapproximatedAddMap(isl::union_map UMap,
class Simplify : public ScopPass {
private:
// / The invocation id (if there are multiple instances in the pass manager's
// / pipeline) to determine which statistics to update.
int CallNo;
// / The last/current SCoP that is/has been processed.
Scop *S;
Expand Down
Expand Up
@@ -176,7 +199,7 @@ class Simplify : public ScopPass {
Stmt.removeSingleMemoryAccess (MA);
OverwritesRemoved++;
TotalOverwritesRemoved++;
TotalOverwritesRemoved[CallNo] ++;
}
// Unconditional writes overwrite other values.
Expand Down
Expand Up
@@ -315,7 +338,7 @@ class Simplify : public ScopPass {
// We removed MA, OtherMA takes its role.
MA = OtherMA;
TotalWritesCoalesced++;
TotalWritesCoalesced[CallNo] ++;
WritesCoalesced++;
// Don't look for more candidates.
Expand Down
Expand Up
@@ -437,7 +460,7 @@ class Simplify : public ScopPass {
Stmt.removeSingleMemoryAccess (MA);
RedundantWritesRemoved++;
TotalRedundantWritesRemoved++;
TotalRedundantWritesRemoved[CallNo] ++;
}
}
}
Expand Down
Expand Up
@@ -476,7 +499,7 @@ class Simplify : public ScopPass {
StmtsRemoved = NumStmtsBefore - S->getSize ();
DEBUG (dbgs () << " Removed " << StmtsRemoved << " (of " << NumStmtsBefore
<< " ) statements\n " );
TotalStmtsRemoved += StmtsRemoved;
TotalStmtsRemoved[CallNo] += StmtsRemoved;
}
// / Remove accesses that have an empty domain.
Expand All
@@ -501,7 +524,7 @@ class Simplify : public ScopPass {
for (MemoryAccess *MA : DeferredRemove) {
Stmt.removeSingleMemoryAccess (MA);
EmptyPartialAccessesRemoved++;
TotalEmptyPartialAccessesRemoved++;
TotalEmptyPartialAccessesRemoved[CallNo] ++;
}
}
}
Expand Down
Expand Up
@@ -530,7 +553,7 @@ class Simplify : public ScopPass {
Stmt->removeSingleMemoryAccess (MA);
DeadAccessesRemoved++;
TotalDeadAccessesRemoved++;
TotalDeadAccessesRemoved[CallNo] ++;
}
// Remove all non-reachable instructions.
Expand All
@@ -548,7 +571,7 @@ class Simplify : public ScopPass {
DEBUG (dbgs () << " Removing " ; Inst->print (dbgs ());
dbgs () << " because it is not used\n " );
DeadInstructionsRemoved++;
TotalDeadInstructionsRemoved++;
TotalDeadInstructionsRemoved[CallNo] ++;
continue ;
}
Expand Down
Expand Up
@@ -595,7 +618,7 @@ class Simplify : public ScopPass {
public:
static char ID;
explicit Simplify () : ScopPass(ID) {}
explicit Simplify (int CallNo = 0 ) : ScopPass(ID), CallNo(CallNo ) {}
virtual void getAnalysisUsage (AnalysisUsage &AU) const override {
AU.addRequiredTransitive <ScopInfoRegionPass>();
Expand All
@@ -610,7 +633,7 @@ class Simplify : public ScopPass {
// Prepare processing of this SCoP.
this ->S = &S;
ScopsProcessed++;
ScopsProcessed[CallNo] ++;
DEBUG (dbgs () << " Removing partial writes that never happen...\n " );
removeEmptyPartialAccesses ();
Expand All
@@ -632,10 +655,18 @@ class Simplify : public ScopPass {
removeUnnecessaryStmts ();
if (isModified ())
ScopsModified++;
ScopsModified[CallNo] ++;
DEBUG (dbgs () << " \n Final Scop:\n " );
DEBUG (dbgs () << S);
auto ScopStats = S.getStatistics ();
NumValueWrites[CallNo] += ScopStats.NumValueWrites ;
NumValueWritesInLoops[CallNo] += ScopStats.NumValueWritesInLoops ;
NumPHIWrites[CallNo] += ScopStats.NumPHIWrites ;
NumPHIWritesInLoops[CallNo] += ScopStats.NumPHIWritesInLoops ;
NumSingletonWrites[CallNo] += ScopStats.NumSingletonWrites ;
NumSingletonWritesInLoops[CallNo] += ScopStats.NumSingletonWritesInLoops ;
return false ;
}
Expand Down
Expand Up
@@ -688,7 +719,7 @@ SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt) {
}
} // namespace polly
Pass *polly::createSimplifyPass () { return new Simplify (); }
Pass *polly::createSimplifyPass (int CallNo ) { return new Simplify (CallNo ); }
INITIALIZE_PASS_BEGIN (Simplify, " polly-simplify" , " Polly - Simplify" , false ,
false )
Expand Down