[PATCH] D57033: [LCSSA] Handle case with single new PHI faster.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 14:53:45 PST 2019
fhahn updated this revision to Diff 183408.
fhahn marked 2 inline comments as done.
fhahn added a comment.
Updated comment, added back conditional.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57033/new/
https://reviews.llvm.org/D57033
Files:
llvm/lib/Transforms/Utils/LCSSA.cpp
Index: llvm/lib/Transforms/Utils/LCSSA.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LCSSA.cpp
+++ llvm/lib/Transforms/Utils/LCSSA.cpp
@@ -197,6 +197,17 @@
continue;
}
+ // If we added a single PHI, it must dominate all uses and we can directly
+ // rename it.
+ if (AddedPHIs.size() == 1) {
+ // Tell the VHs that the uses changed. This updates SCEV's caches.
+ // We might call ValueIsRAUWd multiple times for the same value.
+ if (UseToRewrite->get()->hasValueHandle())
+ ValueHandleBase::ValueIsRAUWd(*UseToRewrite, AddedPHIs[0]);
+ UseToRewrite->set(AddedPHIs[0]);
+ continue;
+ }
+
// Otherwise, do full PHI insertion.
SSAUpdate.RewriteUse(*UseToRewrite);
}
@@ -210,9 +221,12 @@
BasicBlock *UserBB = DVI->getParent();
if (InstBB == UserBB || L->contains(UserBB))
continue;
- // We currently only handle debug values residing in blocks where we have
- // inserted a PHI instruction.
- if (Value *V = SSAUpdate.FindValueForBlock(UserBB))
+ // We currently only handle debug values residing in blocks that were
+ // traversed while rewriting the uses. If we inserted just a single PHI,
+ // we will handle all relevant debug values.
+ Value *V = AddedPHIs.size() == 1 ? AddedPHIs[0]
+ : SSAUpdate.FindValueForBlock(UserBB);
+ if (V)
DVI->setOperand(0, MetadataAsValue::get(Ctx, ValueAsMetadata::get(V)));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57033.183408.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/ee98bf17/attachment.bin>
More information about the llvm-commits
mailing list