[llvm] [Utils] Avoid repeated hash lookups (NFC) (PR #136414)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 19 01:14:00 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/136414
None
>From 274b6cfebb02568b9dd599dfa6992f3eeb03ede6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 19 Apr 2025 00:56:35 -0700
Subject: [PATCH] [Utils] Avoid repeated hash lookups (NFC)
---
.../Transforms/Utils/ScalarEvolutionExpander.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 31d8acb706997..fb5e73727b2ef 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1633,13 +1633,13 @@ void SCEVExpander::replaceCongruentIVInc(
// If this phi has the same width but is more canonical, replace the
// original with it. As part of the "more canonical" determination,
// respect a prior decision to use an IV chain.
- if (OrigPhi->getType() == Phi->getType() &&
- !(ChainedPhis.count(Phi) ||
- isExpandedAddRecExprPHI(OrigPhi, OrigInc, L)) &&
- (ChainedPhis.count(Phi) ||
- isExpandedAddRecExprPHI(Phi, IsomorphicInc, L))) {
- std::swap(OrigPhi, Phi);
- std::swap(OrigInc, IsomorphicInc);
+ if (OrigPhi->getType() == Phi->getType()) {
+ bool Chained = ChainedPhis.contains(Phi);
+ if (!(Chained || isExpandedAddRecExprPHI(OrigPhi, OrigInc, L)) &&
+ (Chained || isExpandedAddRecExprPHI(Phi, IsomorphicInc, L))) {
+ std::swap(OrigPhi, Phi);
+ std::swap(OrigInc, IsomorphicInc);
+ }
}
// Replacing the congruent phi is sufficient because acyclic
More information about the llvm-commits
mailing list