[llvm] 8973be4 - [PredicateInfo] Avoid duplicate stack in scope check (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 20 00:47:37 PDT 2025
Author: Nikita Popov
Date: 2025-06-20T09:47:29+02:00
New Revision: 8973be462c49a7b0a24c61f41e07a721706b1ad8
URL: https://github.com/llvm/llvm-project/commit/8973be462c49a7b0a24c61f41e07a721706b1ad8
DIFF: https://github.com/llvm/llvm-project/commit/8973be462c49a7b0a24c61f41e07a721706b1ad8.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Utils/PredicateInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 778287bb41b60..9b239d9161e7f 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -283,8 +283,7 @@ class PredicateInfoBuilder {
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;
More information about the llvm-commits
mailing list