aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/PredicateInfo.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-06-20 09:46:41 +0200
committerNikita Popov <npopov@redhat.com>2025-06-20 09:47:29 +0200
commit8973be462c49a7b0a24c61f41e07a721706b1ad8 (patch)
treee303a76232657066d8ee9dcef5ad186da939d158 /llvm/lib/Transforms/Utils/PredicateInfo.cpp
parentc361bffa50f1ed790c393ffbab39c2e07dfcb242 (diff)
downloadllvm-8973be462c49a7b0a24c61f41e07a721706b1ad8.zip
llvm-8973be462c49a7b0a24c61f41e07a721706b1ad8.tar.gz
llvm-8973be462c49a7b0a24c61f41e07a721706b1ad8.tar.bz2
[PredicateInfo] Avoid duplicate stack in scope check (NFC)
popStackUntilDFSScope() is going to check this itself, there is no need to do it in advance as well.
Diffstat (limited to 'llvm/lib/Transforms/Utils/PredicateInfo.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PredicateInfo.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 778287b..9b239d9 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -283,8 +283,7 @@ public:
bool PredicateInfoBuilder::stackIsInScope(const ValueDFSStack &Stack,
const ValueDFS &VDUse) const {
- if (Stack.empty())
- return false;
+ assert(!Stack.empty() && "Should not be called with empty stack");
// If it's a phi only use, make sure it's for this phi node edge, and that the
// use is in a phi node. If it's anything else, and the top of the stack is
// a LN_Last def, we need to pop the stack. We deliberately sort phi uses
@@ -677,22 +676,18 @@ void PredicateInfoBuilder::renameUses(SmallVectorImpl<Value *> &OpsToRename) {
LLVM_DEBUG(dbgs() << "Current DFS numbers are (" << VD.DFSIn << ","
<< VD.DFSOut << ")\n");
- bool ShouldPush = (VD.Def || PossibleCopy);
- bool OutOfScope = !stackIsInScope(RenameStack, VD);
- if (OutOfScope || ShouldPush) {
- // Sync to our current scope.
- popStackUntilDFSScope(RenameStack, VD);
- if (ShouldPush) {
- RenameStack.push_back(VD);
- }
+ // Sync to our current scope.
+ popStackUntilDFSScope(RenameStack, VD);
+
+ if (VD.Def || PossibleCopy) {
+ RenameStack.push_back(VD);
+ continue;
}
+
// If we get to this point, and the stack is empty we must have a use
// with no renaming needed, just skip it.
if (RenameStack.empty())
continue;
- // Skip values, only want to rename the uses
- if (VD.Def || PossibleCopy)
- continue;
if (!DebugCounter::shouldExecute(RenameCounter)) {
LLVM_DEBUG(dbgs() << "Skipping execution due to debug counter\n");
continue;