diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-05-14 19:09:33 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-05-15 13:04:10 +0100 |
commit | 28aa7d378abd97cad8e591dd9e9687cda22b0f37 (patch) | |
tree | 629aaedd2b887df68d81293eb58ae652590ce7e3 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 23f7d651b682ea387eaae99f0888e6ca916039cb (diff) | |
download | llvm-28aa7d378abd97cad8e591dd9e9687cda22b0f37.zip llvm-28aa7d378abd97cad8e591dd9e9687cda22b0f37.tar.gz llvm-28aa7d378abd97cad8e591dd9e9687cda22b0f37.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 14f54ed..74bcd0c 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -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; |