[llvm] [LoopIdiom] Use HashRecognize to optimize CRC (PR #143208)
    Piotr Fusik via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jun  9 00:56:38 PDT 2025
    
    
  
================
@@ -592,11 +594,13 @@ HashRecognize::recognizeCRC() const {
   // true even if it is only really used in an outer loop's exit block, since
   // the loop is in LCSSA form.
   auto *ComputedValue = cast<SelectInst>(ConditionalRecurrence.Step);
-  if (none_of(ComputedValue->users(), [Exit](User *U) {
-        auto *UI = dyn_cast<Instruction>(U);
-        return UI && UI->getParent() == Exit;
-      }))
+  auto LCSSAIt = find_if(ComputedValue->users(), [Exit](User *U) {
+    auto *UI = dyn_cast<PHINode>(U);
+    return UI && UI->getNumIncomingValues() == 1 && UI->getParent() == Exit;
+  });
----------------
pfusik wrote:
Is it possible that there are two or more `PHINode`s matching? We are taking one, which seems arbitrary.
https://github.com/llvm/llvm-project/pull/143208
    
    
More information about the llvm-commits
mailing list