[Mlir-commits] [mlir] [mlir] Optimize getting properties on concrete ops (PR #88259)
Jeff Niu
llvmlistbot at llvm.org
Wed Apr 10 04:57:54 PDT 2024
https://github.com/Mogball created https://github.com/llvm/llvm-project/pull/88259
This makes retrieving properties on concrete operations faster by removing a branch when it is known that the operation must have properties.
>From e3e6ab276379e66a8bbda190b5c0cd4ab9253631 Mon Sep 17 00:00:00 2001
From: Mogball <jeff at modular.com>
Date: Wed, 10 Apr 2024 13:52:42 +0200
Subject: [PATCH] [mlir] Optimize getting properties on concrete ops
This makes retrieving properties on concrete operations faster by
removing a branch when it is known that the operation must have
properties.
---
mlir/include/mlir/IR/OpDefinition.h | 2 +-
mlir/include/mlir/IR/Operation.h | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index c177ae3594d11f..2d1dee2303e8f0 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1965,7 +1965,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
if constexpr (!hasProperties())
return getEmptyProperties();
return *getOperation()
- ->getPropertiesStorage()
+ ->getPropertiesStorageUnsafe()
.template as<InferredProperties<T> *>();
}
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 3ffd3517fe5a66..c52a6fcac10c1c 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -895,8 +895,7 @@ class alignas(8) Operation final
/// Returns the properties storage.
OpaqueProperties getPropertiesStorage() {
if (propertiesStorageSize)
- return {
- reinterpret_cast<void *>(getTrailingObjects<detail::OpProperties>())};
+ return getPropertiesStorageUnsafe();
return {nullptr};
}
OpaqueProperties getPropertiesStorage() const {
@@ -905,6 +904,12 @@ class alignas(8) Operation final
getTrailingObjects<detail::OpProperties>()))};
return {nullptr};
}
+ /// Returns the properties storage without checking whether properties are
+ /// present.
+ OpaqueProperties getPropertiesStorageUnsafe() {
+ return {
+ reinterpret_cast<void *>(getTrailingObjects<detail::OpProperties>())};
+ }
/// Return the properties converted to an attribute.
/// This is expensive, and mostly useful when dealing with unregistered
More information about the Mlir-commits
mailing list