Skip to content

Commit f52d466

Browse files
kazutakahirataIanWood1
authored andcommitted
[Utils] Avoid repeated hash lookups (NFC) (llvm#136414)
1 parent 20b4a52 commit f52d466

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,13 +1633,13 @@ void SCEVExpander::replaceCongruentIVInc(
16331633
// If this phi has the same width but is more canonical, replace the
16341634
// original with it. As part of the "more canonical" determination,
16351635
// respect a prior decision to use an IV chain.
1636-
if (OrigPhi->getType() == Phi->getType() &&
1637-
!(ChainedPhis.count(Phi) ||
1638-
isExpandedAddRecExprPHI(OrigPhi, OrigInc, L)) &&
1639-
(ChainedPhis.count(Phi) ||
1640-
isExpandedAddRecExprPHI(Phi, IsomorphicInc, L))) {
1641-
std::swap(OrigPhi, Phi);
1642-
std::swap(OrigInc, IsomorphicInc);
1636+
if (OrigPhi->getType() == Phi->getType()) {
1637+
bool Chained = ChainedPhis.contains(Phi);
1638+
if (!(Chained || isExpandedAddRecExprPHI(OrigPhi, OrigInc, L)) &&
1639+
(Chained || isExpandedAddRecExprPHI(Phi, IsomorphicInc, L))) {
1640+
std::swap(OrigPhi, Phi);
1641+
std::swap(OrigInc, IsomorphicInc);
1642+
}
16431643
}
16441644

16451645
// Replacing the congruent phi is sufficient because acyclic

0 commit comments

Comments
 (0)