[Mlir-commits] [mlir] fb771fe - [mlir] Slightly optimize bytecode op numbering (#88310)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 10 14:34:52 PDT 2024
Author: Jeff Niu
Date: 2024-04-10T23:34:48+02:00
New Revision: fb771fe315654231f613a5501ebd538f036c78b6
URL: https://github.com/llvm/llvm-project/commit/fb771fe315654231f613a5501ebd538f036c78b6
DIFF: https://github.com/llvm/llvm-project/commit/fb771fe315654231f613a5501ebd538f036c78b6.diff
LOG: [mlir] Slightly optimize bytecode op numbering (#88310)
If the bytecode encoding supports properties, then the dictionary
attribute is always the raw dictionary attribute of the operation,
regardless of what it contains. Otherwise, get the dictionary attribute
from the op: if the op does not have properties, then it returns the raw
dictionary, otherwise it returns the combined inherent and discardable
attributes.
Added:
Modified:
mlir/lib/Bytecode/Writer/IRNumbering.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index f36c9ef060b6d7..d2144dd7f33483 100644
--- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp
+++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
@@ -424,22 +424,22 @@ void IRNumberingState::number(Operation &op) {
number(result.getType());
}
- // Only number the operation's dictionary if it isn't empty.
- DictionaryAttr dictAttr = op.getDiscardableAttrDictionary();
// Prior to a version with native property encoding, or when properties are
// not used, we need to number also the merged dictionary containing both the
// inherent and discardable attribute.
- if (config.getDesiredBytecodeVersion() <
- bytecode::kNativePropertiesEncoding ||
- !op.getPropertiesStorage()) {
+ DictionaryAttr dictAttr;
+ if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding)
+ dictAttr = op.getRawDictionaryAttrs();
+ else
dictAttr = op.getAttrDictionary();
- }
+ // Only number the operation's dictionary if it isn't empty.
if (!dictAttr.empty())
number(dictAttr);
// Visit the operation properties (if any) to make sure referenced attributes
// are numbered.
- if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding &&
+ if (config.getDesiredBytecodeVersion() >=
+ bytecode::kNativePropertiesEncoding &&
op.getPropertiesStorageSize()) {
if (op.isRegistered()) {
// Operation that have properties *must* implement this interface.
More information about the Mlir-commits
mailing list