[Local] collectBitParts - early-out from binops. NFCI.

Minor speedup by not bothering to attempt to collect the second operand's bit parts if we already know its failed in the first operand.
This commit is contained in:
Simon Pilgrim 2021-05-14 19:09:33 +01:00
parent 23f7d651b6
commit 28aa7d378a
1 changed files with 10 additions and 7 deletions

View File

@ -2903,17 +2903,18 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
// If this is an or instruction, it may be an inner node of the bswap.
if (match(V, m_Or(m_Value(X), m_Value(Y)))) {
// Check we have both sources and they are from the same provider.
const auto &A =
collectBitParts(X, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
if (!A || !A->Provider)
return Result;
const auto &B =
collectBitParts(Y, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
if (!A || !B)
if (!B || A->Provider != B->Provider)
return Result;
// Try and merge the two together.
if (!A->Provider || A->Provider != B->Provider)
return Result;
Result = BitPart(A->Provider, BitWidth);
for (unsigned BitIdx = 0; BitIdx < BitWidth; ++BitIdx) {
if (A->Provenance[BitIdx] != BitPart::Unset &&
@ -3061,13 +3062,15 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
if (!MatchBitReversals && (ModAmt % 8) != 0)
return Result;
// Check we have both sources and they are from the same provider.
const auto &LHS =
collectBitParts(X, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
if (!LHS || !LHS->Provider)
return Result;
const auto &RHS =
collectBitParts(Y, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
// Check we have both sources and they are from the same provider.
if (!LHS || !RHS || !LHS->Provider || LHS->Provider != RHS->Provider)
if (!RHS || LHS->Provider != RHS->Provider)
return Result;
unsigned StartBitRHS = BitWidth - ModAmt;