[Mlir-commits] [mlir] c949a97 - [mlir] Fold operation trait lookup without a temporary array (NFC) (#226081)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 24 02:29:01 PDT 2026
Author: Mehdi Amini
Date: 2026-09-24T09:28:52Z
New Revision: c949a973db32c7bc80bed6a38057912fea41ddc3
URL: https://github.com/llvm/llvm-project/commit/c949a973db32c7bc80bed6a38057912fea41ddc3
DIFF: https://github.com/llvm/llvm-project/commit/c949a973db32c7bc80bed6a38057912fea41ddc3.diff
LOG: [mlir] Fold operation trait lookup without a temporary array (NFC) (#226081)
Compare trait IDs directly in the generated pack expansion. This avoids
building and scanning a local array in every operation trait lookup.
Assisted-by: Codex
Added:
Modified:
mlir/include/mlir/IR/OpDefinition.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 4741eecb4a874..36bff607c2a69 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1567,11 +1567,7 @@ namespace op_definition_impl {
/// trait types `Traits`.
template <template <typename T> class... Traits>
inline bool hasTrait(TypeID traitID) {
- TypeID traitIDs[] = {TypeID::get<Traits>()...};
- for (unsigned i = 0, e = sizeof...(Traits); i != e; ++i)
- if (traitIDs[i] == traitID)
- return true;
- return false;
+ return ((traitID == TypeID::get<Traits>()) || ...);
}
template <>
inline bool hasTrait<>(TypeID traitID) {
More information about the Mlir-commits
mailing list