[llvm] [SLP]Enable float point math ops as copyables elements. (PR #169857)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 07:01:47 PST 2025


================
@@ -5363,28 +5364,28 @@ class slpvectorizer::BoUpSLP {
           // reordered.
           // Same applies even for non-commutative cmps, because we can invert
           // their predicate potentially and, thus, reorder the operands.
+          constexpr unsigned NumCommutativeOps = 2;
           bool IsCommutativeUser =
-              ::isCommutative(User) ||
-              ::isCommutative(TE->getMatchingMainOpOrAltOp(User), User);
-          if (!IsCommutativeUser && !isa<CmpInst>(User)) {
-            unsigned &OpCnt =
-                OrderedEntriesCount.try_emplace(TE, 0).first->getSecond();
+              U.getOperandNo() < NumCommutativeOps &&
+              (::isCommutative(User) ||
+               ::isCommutative(TE->getMatchingMainOpOrAltOp(User), User));
+          bool IsCommutativeWithSameOps =
+              IsCommutativeUser &&
+              User->getNumOperands() >= NumCommutativeOps &&
+              User->getOperand(0) == User->getOperand(1);
+          if ((!IsCommutativeUser || IsCommutativeWithSameOps) &&
----------------
RKSimon wrote:

OK - please add a short comment para-phrasing that

https://github.com/llvm/llvm-project/pull/169857


More information about the llvm-commits mailing list