[polly] c1cf51e - [Polly][OpTree] Better report applied changes.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 14:22:36 PST 2020
Author: Michael Kruse
Date: 2020-11-11T16:21:48-06:00
New Revision: c1cf51e77701719f3439eed148dfaf44e726c586
URL: https://github.com/llvm/llvm-project/commit/c1cf51e77701719f3439eed148dfaf44e726c586
DIFF: https://github.com/llvm/llvm-project/commit/c1cf51e77701719f3439eed148dfaf44e726c586.diff
LOG: [Polly][OpTree] Better report applied changes.
Print to dbgs() any taken action.
Also, read-only scalars do not require any action unless
-polly-analyze-read-only-scalars=true is used. Better refect this by
using ForwardingAction::triviallyForwardable and thus not bumping the
statistics.
Added:
Modified:
polly/lib/Transform/ForwardOpTree.cpp
polly/test/ForwardOpTree/forward_readonly.ll
Removed:
################################################################################
diff --git a/polly/lib/Transform/ForwardOpTree.cpp b/polly/lib/Transform/ForwardOpTree.cpp
index f2cb80db71a6..d9b19ca11cc3 100644
--- a/polly/lib/Transform/ForwardOpTree.cpp
+++ b/polly/lib/Transform/ForwardOpTree.cpp
@@ -166,11 +166,14 @@ struct ForwardingAction {
}
/// Named ctor: The value can just be used without any preparation.
- static ForwardingAction triviallyForwardable(bool IsProfitable) {
+ static ForwardingAction triviallyForwardable(bool IsProfitable, Value *Val) {
ForwardingAction Result;
Result.Decision =
IsProfitable ? FD_CanForwardProfitably : FD_CanForwardLeaf;
- Result.Execute = []() { return true; };
+ Result.Execute = [=]() {
+ LLVM_DEBUG(dbgs() << " trivially forwarded: " << *Val << "\n");
+ return true;
+ };
return Result;
}
@@ -637,6 +640,8 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
Access = TargetStmt->ensureValueRead(Inst);
Access->setNewAccessRelation(SameVal);
+ LLVM_DEBUG(dbgs() << " forwarded known content of " << *Inst
+ << " which is " << SameVal << "\n");
TotalReloads++;
NumReloads++;
return false;
@@ -703,6 +708,9 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
// operands. This ensures that its operands are inserted before the
// instruction using them.
TargetStmt->prependInstruction(UseInst);
+
+ LLVM_DEBUG(dbgs() << " forwarded speculable instruction: " << *UseInst
+ << "\n");
NumInstructionsCopied++;
TotalInstructionsCopied++;
return true;
@@ -736,7 +744,7 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
case VirtualUse::Block:
case VirtualUse::Hoisted:
// These can be used anywhere without special considerations.
- return ForwardingAction::triviallyForwardable(false);
+ return ForwardingAction::triviallyForwardable(false, UseVal);
case VirtualUse::Synthesizable: {
// Check if the value is synthesizable at the new location as well. This
@@ -752,7 +760,7 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
VirtualUse TargetUse = VirtualUse::create(
S, TargetStmt, TargetStmt->getSurroundingLoop(), UseVal, true);
if (TargetUse.getKind() == VirtualUse::Synthesizable)
- return ForwardingAction::triviallyForwardable(false);
+ return ForwardingAction::triviallyForwardable(false, UseVal);
LLVM_DEBUG(
dbgs() << " Synthesizable would not be synthesizable anymore: "
@@ -761,11 +769,15 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
}
case VirtualUse::ReadOnly: {
+ if (!ModelReadOnlyScalars)
+ return ForwardingAction::triviallyForwardable(false, UseVal);
+
// If we model read-only scalars, we need to create a MemoryAccess for it.
auto ExecAction = [this, TargetStmt, UseVal]() {
- if (ModelReadOnlyScalars)
- TargetStmt->ensureValueRead(UseVal);
+ TargetStmt->ensureValueRead(UseVal);
+ LLVM_DEBUG(dbgs() << " forwarded read-only value " << *UseVal
+ << "\n");
NumReadOnlyCopied++;
TotalReadOnlyCopied++;
diff --git a/polly/test/ForwardOpTree/forward_readonly.ll b/polly/test/ForwardOpTree/forward_readonly.ll
index 215af70d1573..f046b851e755 100644
--- a/polly/test/ForwardOpTree/forward_readonly.ll
+++ b/polly/test/ForwardOpTree/forward_readonly.ll
@@ -42,7 +42,8 @@ return:
; STATS: Statistics {
; STATS: Instructions copied: 1
-; STATS: Read-only accesses copied: 1
+; MODEL: Read-only accesses copied: 1
+; NOMODEL: Read-only accesses copied: 0
; STATS: Operand trees forwarded: 1
; STATS: Statements with forwarded operand trees: 1
; STATS: }
More information about the llvm-commits
mailing list