Skip to content

Conversation

@z1-cciauto
Copy link
Collaborator

No description provided.

yunqingy180 and others added 12 commits October 25, 2025 10:26
…lvm#163893)

Cache extracted elements in lowerShuffleVector(). For example, when
lowering
```
%0:_(<2 x s32>) = G_BUILD_VECTOR %0, %1
%2:_(<N x s32>) = G_SHUFFLE_VECTOR %1, shufflemask(0, 0, 0, 0 ... x N )
```
Currently, we generate `N` `G_EXTRACT_VECTOR_ELT` for each element in
shufflemask. This is undesirable and bloats the code, especially for
larger vectors.

With this change, we only generate one `G_EXTRACT_VECTOR_ELT` from `%0`
and reuse it for all four result elements.
…vm#164543)

This commit enhances the `SpecialCaseList::GlobMatcher` to filter globs
more efficiently by considering both prefixes and suffixes.

Previously, the `GlobMatcher` used a `RadixTree` to store globs based
on their prefixes. This allowed for quick lookup of potential matches
by matching the query string's prefix against the stored prefixes.
However, for globs with common prefixes but different suffixes,
unnecessary glob matching attempts could still occur.

This change introduces a nested `RadixTree` structure:
`PrefixSuffixToGlob: RadixTree<Prefix, RadixTree<Suffix, Globs>>`.
Now, when a query string is matched, it first finds matching prefixes,
and then within those prefix matches, it further filters by matching
the reversed suffix of the query string against the reversed suffixes
of the globs. This significantly reduces the number of `Glob::match`
calls, especially for large special case lists with many globs sharing
common prefixes but differing in their suffixes.

According to SpecialCaseListBM:

Lookup benchmarks (significant improvements):
```
OVERALL_GEOMEAN                       -0.5815
```

Lookup `*suffix` and `prefix*suffix` like benchmarks (huge
improvements):
```
OVERALL_GEOMEAN                       -0.9316
```

https://gist.github.com/vitalybuka/e586751902760ced6beefcdf0d7b26fd
This patch tightens the static_assert.  FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.
This patch uses std::scoped_lock to ensure the mutex is released via
RAII, improving robustness.
DenseMap.h has:

- DenseMapBase::copyFrom
- DenseMap::copyFrom
- SmallDenseMap::copyFrom

The latter two clear and set up the storage again before delegating
DenseMapBase::copyFrom to do the actual work of copying buckets.

This patch consolidates all these into DenseMapBase::copyFrom while
eliminating name shadowing concerns.  Note that DenseMap::copyFrom and
SmallDenseMap::copyFrom are nearly identical, and they can be made
identical with small adjustments:

- Set NumEntries and NumTombstones to 0 unconditionally.
- Teach SmallDenseMap::allocateBuckets to always return true.

This patch essentially applies these adjustments and then "inlines"
the identical function body to the beginning of
DenseMapBase::copyFrom.

This patch de-templatizes DenseMapBase::copyFrom because nobody calls
it with any type other than DerivedT.
This patch removes getEmptyKey, getTombstoneKey, and getHashValue from
DenseMapBase.  These forwarder methods do not really encapsulate
KeyInfoT.  Many of their callers already mention KeyInfoT::isEqual for
example.

An existing static_assert is moved to another method.  Note that it
must live in a method for type completeness reasons.
Without this patch, DenseMap and SmallDenseMap have distinct
implementations of shrink_and_clear.  These implementations mix a
common high-level algorithm with class-specific logic.

This patch moves the common algorithm into
DenseMapBase::shrink_and_clear.  A new private helper,
planShrinkAndClear, now handles the class-specific logic for deciding
whether to shrink the buffer.  The base class method now serves as the
single public entry point.
…lvm#165067)

Based on some recent discussion in llvm#162007. Documenting this in the best
practices page so we have something easy to point to in code
review/reference for ourselves now that the repository has been cleaned
up.
@z1-cciauto z1-cciauto requested a review from a team October 25, 2025 19:06
@z1-cciauto
Copy link
Collaborator Author

@ronlieb ronlieb merged commit 83b1825 into amd-staging Oct 25, 2025
7 checks passed
@ronlieb ronlieb deleted the upstream_merge_202510251506 branch October 25, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants