[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.
This commit is contained in:
Kazu Hirata 2025-02-04 09:10:40 -08:00 committed by GitHub
parent a207f60727
commit 0c7bd879d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1184,22 +1184,22 @@ static std::optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
for (unsigned Idx = 0, EIdx = PN->getNumIncomingValues(); Idx < EIdx; Idx++) {
Incoming = PN->getIncomingValue(Idx);
IncomingBlock = PN->getIncomingBlock(Idx);
// If the incoming block isn't in the region, we don't have to worry about
// this incoming value.
if (!Blocks.contains(IncomingBlock))
continue;
// If we cannot find a GVN, and the incoming block is included in the region
// this means that the input to the PHINode is not included in the region we
// are trying to analyze, meaning, that if it was outlined, we would be
// adding an extra input. We ignore this case for now, and so ignore the
// region.
std::optional<unsigned> OGVN = Cand.getGVN(Incoming);
if (!OGVN && Blocks.contains(IncomingBlock)) {
if (!OGVN) {
Region.IgnoreRegion = true;
return std::nullopt;
}
// If the incoming block isn't in the region, we don't have to worry about
// this incoming value.
if (!Blocks.contains(IncomingBlock))
continue;
// Collect the canonical numbers of the values in the PHINode.
unsigned GVN = *OGVN;
OGVN = Cand.getCanonicalNum(GVN);