Skip to content

Commit f2ade91

Browse files
author
Jeff Niu
authored
[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.
1 parent 8d206f5 commit f2ade91

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mlir/include/mlir/IR/OpDefinition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ class Op : public OpState, public Traits<ConcreteType>... {
19651965
if constexpr (!hasProperties())
19661966
return getEmptyProperties();
19671967
return *getOperation()
1968-
->getPropertiesStorage()
1968+
->getPropertiesStorageUnsafe()
19691969
.template as<InferredProperties<T> *>();
19701970
}
19711971

mlir/include/mlir/IR/Operation.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,7 @@ class alignas(8) Operation final
895895
/// Returns the properties storage.
896896
OpaqueProperties getPropertiesStorage() {
897897
if (propertiesStorageSize)
898-
return {
899-
reinterpret_cast<void *>(getTrailingObjects<detail::OpProperties>())};
898+
return getPropertiesStorageUnsafe();
900899
return {nullptr};
901900
}
902901
OpaqueProperties getPropertiesStorage() const {
@@ -905,6 +904,12 @@ class alignas(8) Operation final
905904
getTrailingObjects<detail::OpProperties>()))};
906905
return {nullptr};
907906
}
907+
/// Returns the properties storage without checking whether properties are
908+
/// present.
909+
OpaqueProperties getPropertiesStorageUnsafe() {
910+
return {
911+
reinterpret_cast<void *>(getTrailingObjects<detail::OpProperties>())};
912+
}
908913

909914
/// Return the properties converted to an attribute.
910915
/// This is expensive, and mostly useful when dealing with unregistered

0 commit comments

Comments
 (0)