[llvm] [SLP] Fix isCommutative to check uses of the original instruction instead of the converted instruction. (PR #143094)
    Han-Kuan Chen via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Jun  7 05:41:15 PDT 2025
    
    
  
================
@@ -536,14 +542,16 @@ static bool isCommutative(Instruction *I) {
                           Flag->isOne());
                 })) ||
            (BO->getOpcode() == Instruction::FSub &&
-            !BO->hasNUsesOrMore(UsesLimit) &&
-            all_of(BO->uses(), [](const Use &U) {
+            !InstWithUses->hasNUsesOrMore(UsesLimit) &&
+            all_of(InstWithUses->uses(), [](const Use &U) {
               return match(U.getUser(),
                            m_Intrinsic<Intrinsic::fabs>(m_Specific(U.get())));
             }));
   return I->isCommutative();
 }
 
+static bool isCommutative(Instruction *I) { return isCommutative(I, I); }
----------------
HanKuanChen wrote:
We need it. `isCommutative(Instruction *I)` is used widely. Only interchangeable instruction analysis will change the parameter (InstWithUses).
https://github.com/llvm/llvm-project/pull/143094
    
    
More information about the llvm-commits
mailing list