Skip to content

Commit 32fe8ff

Browse files
author
Mogball
committed
[mlir] Slightly optimize bytecode op numbering
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.
1 parent f81879c commit 32fe8ff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mlir/lib/Bytecode/Writer/IRNumbering.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,22 +424,22 @@ void IRNumberingState::number(Operation &op) {
424424
number(result.getType());
425425
}
426426

427-
// Only number the operation's dictionary if it isn't empty.
428-
DictionaryAttr dictAttr = op.getDiscardableAttrDictionary();
429427
// Prior to a version with native property encoding, or when properties are
430428
// not used, we need to number also the merged dictionary containing both the
431429
// inherent and discardable attribute.
432-
if (config.getDesiredBytecodeVersion() <
433-
bytecode::kNativePropertiesEncoding ||
434-
!op.getPropertiesStorage()) {
430+
DictionaryAttr dictAttr;
431+
if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding)
432+
dictAttr = op.getRawDictionaryAttrs();
433+
else
435434
dictAttr = op.getAttrDictionary();
436-
}
435+
// Only number the operation's dictionary if it isn't empty.
437436
if (!dictAttr.empty())
438437
number(dictAttr);
439438

440439
// Visit the operation properties (if any) to make sure referenced attributes
441440
// are numbered.
442-
if (config.getDesiredBytecodeVersion() >= bytecode::kNativePropertiesEncoding &&
441+
if (config.getDesiredBytecodeVersion() >=
442+
bytecode::kNativePropertiesEncoding &&
443443
op.getPropertiesStorageSize()) {
444444
if (op.isRegistered()) {
445445
// Operation that have properties *must* implement this interface.

0 commit comments

Comments
 (0)