[llvm] [SLP][NFC] Use static_assert to confirm SupportedOps is sorted (PR #181397)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 10:40:58 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: Ryan Buchner (bababuck)
<details>
<summary>Changes</summary>
Can be checked at compile time.
---
Full diff: https://github.com/llvm/llvm-project/pull/181397.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+3-3)
``````````diff
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.");
``````````
</details>
https://github.com/llvm/llvm-project/pull/181397
More information about the llvm-commits
mailing list