[Mlir-commits] [mlir] f2ade91 - [mlir] Optimize getting properties on concrete ops (#88259)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 10 05:11:50 PDT 2024
Author: Jeff Niu
Date: 2024-04-10T14:11:45+02:00
New Revision: f2ade91a9fe7c222ea919748d30b74397911ecc8
URL: https://github.com/llvm/llvm-project/commit/f2ade91a9fe7c222ea919748d30b74397911ecc8
DIFF: https://github.com/llvm/llvm-project/commit/f2ade91a9fe7c222ea919748d30b74397911ecc8.diff
LOG: [mlir] Optimize getting properties on concrete ops (#88259)
This makes retrieving properties on concrete operations faster by
removing a branch when it is known that the operation must have
properties.
Added:
Modified:
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Operation.h
Removed:
################################################################################
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