[Mlir-commits] [mlir] [mlir] Skip the promised-interface lookup for an emptied dialect set (NFC) (PR #219545)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 31 22:48:14 PDT 2026
================
@@ -228,6 +228,9 @@ class Dialect {
void handleUseOfUndefinedPromisedInterface(TypeID interfaceRequestorID,
TypeID interfaceID,
StringRef interfaceName = "") {
+ // Most dialects promise nothing; skip hashing a key and probing the set.
+ if (unresolvedPromisedInterfaces.empty())
+ return;
if (unresolvedPromisedInterfaces.count(
----------------
khaki3 wrote:
| variant | mlir-opt | clang | total reach |
|---|---:|---:|---|
| `Dialect` guard (This PR) | -0.290% | 0.00% | MLIR only |
| **replace** | **-0.277%** | **-0.133%** | all of LLVM |
| replace + `LLVM_UNLIKELY` | -0.274% | -0.007% | hint wrong: empty is the common case |
| both (replace + `Dialect` guard) | -0.277% | -0.133% | no gain over replace |
@kuhar, do you think a 0.133% instruction count reduction is worth landing? If so, I'll check profile more cases.
```patch
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -722,7 +722,10 @@ private:
template <typename LookupKeyT>
const BucketT *doFind(const LookupKeyT &Val) const {
auto [BucketsPtr, U, NumBuckets] = getRep();
- if (NumBuckets == 0)
+ // Subsumes the NumBuckets == 0 case: there are no entries without
+ // buckets, so a non-zero entry count implies NumBuckets != 0 and the
+ // Mask below is safe.
+ if (getNumEntries() == 0)
return nullptr;
const unsigned Mask = NumBuckets - 1;
```
https://github.com/llvm/llvm-project/pull/219545
More information about the Mlir-commits
mailing list