Skip to content

Commit 0c7bd87

Browse files
[IPO] Avoid repeated hash lookups (NFC) (#125639)
The two "if" conditions are mutually exclusive, so we can put them in any order. Reversing the order allows us to remove Blocks.contains(IncomingBlock) in one of the "if" conditions.
1 parent a207f60 commit 0c7bd87

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Transforms/IPO/IROutliner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,22 +1184,22 @@ static std::optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
11841184
for (unsigned Idx = 0, EIdx = PN->getNumIncomingValues(); Idx < EIdx; Idx++) {
11851185
Incoming = PN->getIncomingValue(Idx);
11861186
IncomingBlock = PN->getIncomingBlock(Idx);
1187+
// If the incoming block isn't in the region, we don't have to worry about
1188+
// this incoming value.
1189+
if (!Blocks.contains(IncomingBlock))
1190+
continue;
1191+
11871192
// If we cannot find a GVN, and the incoming block is included in the region
11881193
// this means that the input to the PHINode is not included in the region we
11891194
// are trying to analyze, meaning, that if it was outlined, we would be
11901195
// adding an extra input. We ignore this case for now, and so ignore the
11911196
// region.
11921197
std::optional<unsigned> OGVN = Cand.getGVN(Incoming);
1193-
if (!OGVN && Blocks.contains(IncomingBlock)) {
1198+
if (!OGVN) {
11941199
Region.IgnoreRegion = true;
11951200
return std::nullopt;
11961201
}
11971202

1198-
// If the incoming block isn't in the region, we don't have to worry about
1199-
// this incoming value.
1200-
if (!Blocks.contains(IncomingBlock))
1201-
continue;
1202-
12031203
// Collect the canonical numbers of the values in the PHINode.
12041204
unsigned GVN = *OGVN;
12051205
OGVN = Cand.getCanonicalNum(GVN);

0 commit comments

Comments
 (0)