[llvm] f290379 - [SLP][NFC] Use static_assert to confirm SupportedOps is sorted (#181397)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 11:31:04 PST 2026
Author: Ryan Buchner
Date: 2026-02-13T11:30:59-08:00
New Revision: f2903793debde9f41b9083df225c17491a0396c4
URL: https://github.com/llvm/llvm-project/commit/f2903793debde9f41b9083df225c17491a0396c4
DIFF: https://github.com/llvm/llvm-project/commit/f2903793debde9f41b9083df225c17491a0396c4.diff
LOG: [SLP][NFC] Use static_assert to confirm SupportedOps is sorted (#181397)
Can be checked at compile time.
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 4197c8f64d8eb..a74205c385e9b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -954,6 +954,8 @@ class BinOpSameOpcodeHelper {
constexpr static std::initializer_list<unsigned> SupportedOp = {
Instruction::Add, Instruction::Sub, Instruction::Mul, Instruction::Shl,
Instruction::AShr, Instruction::And, Instruction::Or, Instruction::Xor};
+ static_assert(llvm::is_sorted_constexpr(SupportedOp) &&
+ "SupportedOp is not sorted.");
enum : MaskType {
ShlBIT = 0b1,
AShrBIT = 0b10,
@@ -1158,9 +1160,7 @@ class BinOpSameOpcodeHelper {
public:
BinOpSameOpcodeHelper(const Instruction *MainOp,
const Instruction *AltOp = nullptr)
- : MainOp(MainOp), AltOp(AltOp) {
- assert(is_sorted(SupportedOp) && "SupportedOp is not sorted.");
- }
+ : MainOp(MainOp), AltOp(AltOp) {}
bool add(const Instruction *I) {
assert(isa<BinaryOperator>(I) &&
"BinOpSameOpcodeHelper only accepts BinaryOperator.");
More information about the llvm-commits
mailing list