[llvm] af4581e - [SLP] make commutative check apply only to binops; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 08:01:33 PDT 2020
Author: Sanjay Patel
Date: 2020-08-30T10:55:44-04:00
New Revision: af4581e8ab1648ff4df0b7fe3769160e6b9f2617
URL: https://github.com/llvm/llvm-project/commit/af4581e8ab1648ff4df0b7fe3769160e6b9f2617
DIFF: https://github.com/llvm/llvm-project/commit/af4581e8ab1648ff4df0b7fe3769160e6b9f2617.diff
LOG: [SLP] make commutative check apply only to binops; NFC
As discussed in D86798, it's not clear if the caller code
works with a more liberal definition of "commutative" that
includes intrinsics like min/max. This makes the binop
restriction (current functionality is unchanged) explicit
until the code is audited/tested.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e5e3d3611d07..ec138bf2b7c8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -235,11 +235,16 @@ static bool isSplat(ArrayRef<Value *> VL) {
return true;
}
-/// \returns True if \p I is commutative, handles CmpInst as well as Instruction.
+/// \returns True if \p I is commutative, handles CmpInst and BinaryOperator.
static bool isCommutative(Instruction *I) {
- if (auto *IC = dyn_cast<CmpInst>(I))
- return IC->isCommutative();
- return I->isCommutative();
+ if (auto *Cmp = dyn_cast<CmpInst>(I))
+ return Cmp->isCommutative();
+ if (auto *BO = dyn_cast<BinaryOperator>(I))
+ return BO->isCommutative();
+ // TODO: This should check for generic Instruction::isCommutative(), but
+ // we need to confirm that the caller code correctly handles Intrinsics
+ // for example (does not have 2 operands).
+ return false;
}
/// Checks if the vector of instructions can be represented as a shuffle, like:
More information about the llvm-commits
mailing list