Skip to content

Commit 886b494

Browse files
committed
[HashRecognize] Address review
1 parent 1a4cda3 commit 886b494

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

llvm/lib/Analysis/HashRecognize.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ KnownBits ValueEvolution::computeInstr(const Instruction *I) {
197197
if (match(I, m_Select(m_ICmp(Pred, m_Value(L), m_Value(R)), m_Instruction(TV),
198198
m_Instruction(FV)))) {
199199
Visited.insert(cast<Instruction>(I->getOperand(0)));
200-
Visited.insert(TV);
201-
Visited.insert(FV);
202200

203201
// We need to check LCR against [0, 2) in the little-endian case, because
204202
// the RCR check is insufficient: it is simply [0, 1).
@@ -224,10 +222,14 @@ KnownBits ValueEvolution::computeInstr(const Instruction *I) {
224222

225223
// We only compute KnownBits of either TV or FV, as the other value would
226224
// just be a bit-shift as checked by isBigEndianBitShift.
227-
if (AllowedR == CheckRCR)
225+
if (AllowedR == CheckRCR) {
226+
Visited.insert(FV);
228227
return compute(TV);
229-
if (AllowedR.inverse() == CheckRCR)
228+
}
229+
if (AllowedR.inverse() == CheckRCR) {
230+
Visited.insert(TV);
230231
return compute(FV);
232+
}
231233

232234
ErrStr = "Bad RHS of significant-bit-check";
233235
return {BitWidth};
@@ -650,16 +652,14 @@ HashRecognize::recognizeCRC() const {
650652
KnownBits ResultBits = VE.KnownPhis.at(ConditionalRecurrence.Phi);
651653

652654
// There must be exactly four unvisited instructions, corresponding to the
653-
// IndVar PHI:
654-
// IndVar
655-
// Latch->getTerminator()
656-
// L.getLatchCmpInst(),
657-
// IndVar->getIncomingValueForBlock(Latch))
658-
//
659-
// Any other unvisited instructions from the KnownBits propagation can
660-
// complicate the optimization, which would just replace the entire loop with
661-
// the table-lookup version of the hash algorithm.
662-
if (std::distance(Latch->begin(), Latch->end()) != VE.Visited.size() + 4)
655+
// IndVar PHI. Any other unvisited instructions from the KnownBits propagation
656+
// can complicate the optimization, which replaces the entire loop with the
657+
// table-lookup version of the hash algorithm.
658+
std::initializer_list<const Instruction *> AugmentVisited = {
659+
IndVar, Latch->getTerminator(), L.getLatchCmpInst(),
660+
cast<Instruction>(IndVar->getIncomingValueForBlock(Latch))};
661+
VE.Visited.insert_range(AugmentVisited);
662+
if (std::distance(Latch->begin(), Latch->end()) != VE.Visited.size())
663663
return "Found stray unvisited instructions";
664664

665665
unsigned N = std::min(TC, ResultBits.getBitWidth());

0 commit comments

Comments
 (0)