Polly 22.0.0git
PruneUnprofitable.cpp
Go to the documentation of this file.
1//===- PruneUnprofitable.cpp ----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Mark a SCoP as unfeasible if not deemed profitable to optimize.
10//
11//===----------------------------------------------------------------------===//
12
14#include "polly/ScopDetection.h"
15#include "polly/ScopInfo.h"
16#include "llvm/ADT/Statistic.h"
17#include "llvm/IR/DebugLoc.h"
18#include "llvm/Support/Debug.h"
19#include "llvm/Support/raw_ostream.h"
20
21using namespace llvm;
22using namespace polly;
23
25#define DEBUG_TYPE "polly-prune-unprofitable"
26
27namespace {
28
29STATISTIC(ScopsProcessed,
30 "Number of SCoPs considered for unprofitability pruning");
31STATISTIC(ScopsPruned, "Number of pruned SCoPs because it they cannot be "
32 "optimized in a significant way");
33STATISTIC(ScopsSurvived, "Number of SCoPs after pruning");
34
35STATISTIC(NumPrunedLoops, "Number of pruned loops");
36STATISTIC(NumPrunedBoxedLoops, "Number of pruned boxed loops");
37STATISTIC(NumPrunedAffineLoops, "Number of pruned affine loops");
38
39STATISTIC(NumLoopsInScop, "Number of loops in scops after pruning");
40STATISTIC(NumBoxedLoops, "Number of boxed loops in SCoPs after pruning");
41STATISTIC(NumAffineLoops, "Number of affine loops in SCoPs after pruning");
42
43static void updateStatistics(Scop &S, bool Pruned) {
44 Scop::ScopStatistics ScopStats = S.getStatistics();
45 if (Pruned) {
46 ScopsPruned++;
47 NumPrunedLoops += ScopStats.NumAffineLoops + ScopStats.NumBoxedLoops;
48 NumPrunedBoxedLoops += ScopStats.NumBoxedLoops;
49 NumPrunedAffineLoops += ScopStats.NumAffineLoops;
50 } else {
51 ScopsSurvived++;
52 NumLoopsInScop += ScopStats.NumAffineLoops + ScopStats.NumBoxedLoops;
53 NumBoxedLoops += ScopStats.NumBoxedLoops;
54 NumAffineLoops += ScopStats.NumAffineLoops;
55 }
56}
57} // namespace
58
62 dbgs() << "NOTE: -polly-process-unprofitable active, won't prune "
63 "anything\n");
64 return false;
65 }
66
67 ScopsProcessed++;
68
69 if (!S.isProfitable(true)) {
71 dbgs() << "SCoP pruned because it probably cannot be optimized in "
72 "a significant way\n");
73 S.invalidate(PROFITABLE, DebugLoc());
74 updateStatistics(S, true);
75 } else {
76 updateStatistics(S, false);
77 }
78
79 return false;
80}
#define POLLY_DEBUG(X)
Definition PollyDebug.h:23
STATISTIC(ScopFound, "Number of valid Scops")
Static Control Part.
Definition ScopInfo.h:1625
#define S(TYPE, NAME)
bool runPruneUnprofitable(Scop &S)
bool PollyProcessUnprofitable
@ PROFITABLE
Definition ScopHelper.h:48