[mlir][Value] Add getNumUses, hasNUses, and hasNUsesOrMore to Value (#142084)

We already have hasOneUse. Like llvm::Value we provide helper methods to
query the number of uses of a Value. Add unittests for Value, because
that was missing.

---------

Co-authored-by: Michael Maitland <michaelmaitland@meta.com>
This commit is contained in:
Michael Maitland
2025-05-30 00:39:45 -04:00
committed by GitHub
parent f5d3470d42
commit 7454098a9e
8 changed files with 125 additions and 17 deletions

View File

@@ -1993,8 +1993,7 @@ LogicalResult BytecodeReader::Impl::sortUseListOrder(Value value) {
UseListOrderStorage customOrder =
valueToUseListMap.at(value.getAsOpaquePointer());
SmallVector<unsigned, 4> shuffle = std::move(customOrder.indices);
uint64_t numUses =
std::distance(value.getUses().begin(), value.getUses().end());
uint64_t numUses = value.getNumUses();
// If the encoding was a pair of indices `(src, dst)` for every permutation,
// reconstruct the shuffle vector for every use. Initialize the shuffle vector