aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-04-28 23:08:27 +0000
committerAdam Nemet <anemet@apple.com>2016-04-28 23:08:27 +0000
commit7f38e1199a5b25100eab7cb7f60391e0748a3b57 (patch)
tree002a1063a754f4f11b8be76558fee58ef59de1e4 /llvm/lib/Transforms/Scalar/LoopDistribute.cpp
parent50316d95a935161b8626e637dbc29f14bc813b77 (diff)
downloadllvm-7f38e1199a5b25100eab7cb7f60391e0748a3b57.zip
llvm-7f38e1199a5b25100eab7cb7f60391e0748a3b57.tar.gz
llvm-7f38e1199a5b25100eab7cb7f60391e0748a3b57.tar.bz2
[LoopDist] Add helper to print debug message when distribution fails. NFC
This will form the basis to emit optimization remarks (-Rpass*). llvm-svn: 267950
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopDistribute.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopDistribute.cpp43
1 files changed, 20 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
index 8bafb2d..7fa678a 100644
--- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -601,27 +601,20 @@ public:
<< "\" checking " << *L << "\n");
BasicBlock *PH = L->getLoopPreheader();
- if (!PH) {
- DEBUG(dbgs() << "Skipping; no preheader");
- return false;
- }
- if (!L->getExitBlock()) {
- DEBUG(dbgs() << "Skipping; multiple exit blocks");
- return false;
- }
+ if (!PH)
+ return fail("Skipping; no preheader");
+ if (!L->getExitBlock())
+ return fail("Skipping; multiple exit blocks");
// LAA will check that we only have a single exiting block.
// Currently, we only distribute to isolate the part of the loop with
// dependence cycles to enable partial vectorization.
- if (LAI.canVectorizeMemory()) {
- DEBUG(dbgs() << "Skipping; memory operations are safe for vectorization");
- return false;
- }
+ if (LAI.canVectorizeMemory())
+ return fail("Skipping; memory operations are safe for vectorization");
+
auto *Dependences = LAI.getDepChecker().getDependences();
- if (!Dependences || Dependences->empty()) {
- DEBUG(dbgs() << "Skipping; No unsafe dependences to isolate");
- return false;
- }
+ if (!Dependences || Dependences->empty())
+ return fail("Skipping; No unsafe dependences to isolate");
InstPartitionContainer Partitions(L, LI, DT);
@@ -674,14 +667,14 @@ public:
DEBUG(dbgs() << "Seeded partitions:\n" << Partitions);
if (Partitions.getSize() < 2)
- return false;
+ return fail("cannot isolate unsafe dependencies");
// Run the merge heuristics: Merge non-cyclic adjacent partitions since we
// should be able to vectorize these together.
Partitions.mergeBeforePopulating();
DEBUG(dbgs() << "\nMerged partitions:\n" << Partitions);
if (Partitions.getSize() < 2)
- return false;
+ return fail("cannot isolate unsafe dependencies");
// Now, populate the partitions with non-memory operations.
Partitions.populateUsedSet();
@@ -693,17 +686,15 @@ public:
DEBUG(dbgs() << "\nPartitions merged to ensure unique loads:\n"
<< Partitions);
if (Partitions.getSize() < 2)
- return false;
+ return fail("cannot isolate unsafe dependencies");
}
// Don't distribute the loop if we need too many SCEV run-time checks.
const SCEVUnionPredicate &Pred = LAI.PSE.getUnionPredicate();
if (Pred.getComplexity() > (IsForced.getValueOr(false)
? PragmaDistributeSCEVCheckThreshold
- : DistributeSCEVCheckThreshold)) {
- DEBUG(dbgs() << "Too many SCEV run-time checks needed.\n");
- return false;
- }
+ : DistributeSCEVCheckThreshold))
+ return fail("Too many SCEV run-time checks needed.\n");
DEBUG(dbgs() << "\nDistributing loop: " << *L << "\n");
// We're done forming the partitions set up the reverse mapping from
@@ -752,6 +743,12 @@ public:
return true;
}
+ /// \brief Provide diagnostics then \return with false.
+ bool fail(llvm::StringRef Message) {
+ DEBUG(dbgs() << Message << "\n");
+ return false;
+ }
+
/// \brief Return if distribution forced to be enabled/disabled for the loop.
///
/// If the optional has a value, it indicates whether distribution was forced