[llvm] [SLP]Enable float point math ops as copyables elements. (PR #169857)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 3 09:54:12 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) &&
----------------
alexey-bataev wrote:
It is a bugfix for handling commutative instructions with the same operands. If both operands of the commutative instructions are the same values, we do not need to consider the instruction as commutative; better to consider it as noncommutative, since operand interchange does not change anything
https://github.com/llvm/llvm-project/pull/169857
More information about the llvm-commits
mailing list