mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 15:36:58 +00:00
[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:
parent
a207f60727
commit
0c7bd879d2
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user