[PATCH] D126523: [MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 14 04:30:20 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bf27918144c: [MachineSSAUpdater] compile time improvement in GetValueInMiddleOfBlock (authored by skatkov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126523/new/
https://reviews.llvm.org/D126523
Files:
llvm/lib/CodeGen/MachineSSAUpdater.cpp
llvm/lib/Transforms/Utils/SSAUpdater.cpp
Index: llvm/lib/Transforms/Utils/SSAUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SSAUpdater.cpp
+++ llvm/lib/Transforms/Utils/SSAUpdater.cpp
@@ -100,6 +100,14 @@
if (!HasValueForBlock(BB))
return GetValueAtEndOfBlock(BB);
+ // Ok, we have already got a value for this block. If it is out of our block
+ // or it is a phi - we can re-use it as it will be defined in the middle of
+ // block as well.
+ Value *defV = FindValueForBlock(BB);
+ if (auto I = dyn_cast<Instruction>(defV))
+ if (isa<PHINode>(I) || I->getParent() != BB)
+ return defV;
+
// Otherwise, we have the hard case. Get the live-in values for each
// predecessor.
SmallVector<std::pair<BasicBlock *, Value *>, 8> PredValues;
Index: llvm/lib/CodeGen/MachineSSAUpdater.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSSAUpdater.cpp
+++ llvm/lib/CodeGen/MachineSSAUpdater.cpp
@@ -152,6 +152,14 @@
if (!HasValueForBlock(BB))
return GetValueAtEndOfBlockInternal(BB, ExistingValueOnly);
+ // Ok, we have already got a value for this block. If it is out of our block
+ // or it is a phi - we can re-use it as it will be defined in the middle of
+ // block as well.
+ Register defR = getAvailableVals(AV).lookup(BB);
+ if (auto I = MRI->getVRegDef(defR))
+ if (I->isPHI() || I->getParent() != BB)
+ return defR;
+
// If there are no predecessors, just return undef.
if (BB->pred_empty()) {
// If we cannot insert new instructions, just return $noreg.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126523.436736.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220614/b9f24811/attachment.bin>
More information about the llvm-commits
mailing list