@@ -468,8 +468,11 @@ std::variant<PolynomialInfo, StringRef> HashRecognize::recognizeCRC() const {
468468
469469 // Ensure that the PHIs have exactly two uses:
470470 // the bit-shift, and the XOR (or a cast feeding into the XOR).
471+ // Also ensure that the SimpleRecurrence's evolution doesn't have stray
472+ // users.
471473 if (!ConditionalRecurrence.Phi ->hasNUses (2 ) ||
472- !SimpleRecurrence.Phi ->hasNUses (2 ))
474+ !SimpleRecurrence.Phi ->hasNUses (2 ) ||
475+ SimpleRecurrence.BO ->getUniqueUndroppableUser () != SimpleRecurrence.Phi )
473476 return " Recurrences have stray uses" ;
474477
475478 // Check that the SelectInst ConditionalRecurrence.Step is conditional on
@@ -487,14 +490,6 @@ std::variant<PolynomialInfo, StringRef> HashRecognize::recognizeCRC() const {
487490 : LHS->getType ()->getIntegerBitWidth ()))
488491 return " Loop iterations exceed bitwidth of data" ;
489492
490- // Make sure that the simple recurrence evolution isn't used in the exit
491- // block.
492- if (SimpleRecurrence && any_of (SimpleRecurrence.BO ->users (), [Exit](User *U) {
493- auto *UI = dyn_cast<Instruction>(U);
494- return UI && UI->getParent () == Exit;
495- }))
496- return " Recurrences have stray uses" ;
497-
498493 // Make sure that the computed value is used in the exit block: this should be
499494 // true even if it is only really used in an outer loop's exit block, since
500495 // the loop is in LCSSA form.
0 commit comments