[llvm] f345d9b - [IVDesc] Improve isConditionalRdxPattern (NFC) (#162818)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 14 03:41:51 PDT 2025


Author: Ramkumar Ramachandra
Date: 2025-10-14T11:41:47+01:00
New Revision: f345d9b58e19b77c95553a220fc5a3f7663e9cb4

URL: https://github.com/llvm/llvm-project/commit/f345d9b58e19b77c95553a220fc5a3f7663e9cb4
DIFF: https://github.com/llvm/llvm-project/commit/f345d9b58e19b77c95553a220fc5a3f7663e9cb4.diff

LOG: [IVDesc] Improve isConditionalRdxPattern (NFC) (#162818)

Added: 
    

Modified: 
    llvm/lib/Analysis/IVDescriptors.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index b8c540ce4b99d..9f8ac6e8e2e0b 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -849,17 +849,12 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
 /// %sum.2 = select %cmp, %add, %sum.1
 RecurrenceDescriptor::InstDesc
 RecurrenceDescriptor::isConditionalRdxPattern(Instruction *I) {
-  SelectInst *SI = dyn_cast<SelectInst>(I);
-  if (!SI)
-    return InstDesc(false, I);
-
-  CmpInst *CI = dyn_cast<CmpInst>(SI->getCondition());
+  Value *TrueVal, *FalseVal;
   // Only handle single use cases for now.
-  if (!CI || !CI->hasOneUse())
+  if (!match(I,
+             m_Select(m_OneUse(m_Cmp()), m_Value(TrueVal), m_Value(FalseVal))))
     return InstDesc(false, I);
 
-  Value *TrueVal = SI->getTrueValue();
-  Value *FalseVal = SI->getFalseValue();
   // Handle only when either of operands of select instruction is a PHI
   // node for now.
   if ((isa<PHINode>(TrueVal) && isa<PHINode>(FalseVal)) ||
@@ -886,7 +881,7 @@ RecurrenceDescriptor::isConditionalRdxPattern(Instruction *I) {
   if (!IPhi || IPhi != FalseVal)
     return InstDesc(false, I);
 
-  return InstDesc(true, SI);
+  return InstDesc(true, I);
 }
 
 RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(


        


More information about the llvm-commits mailing list