{{ message }}
Add SVE implementation of replace#6195
Open
hazzlim wants to merge 11 commits into
Open
Conversation
StephanTLavavej
approved these changes
Apr 3, 2026
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an SVE-backed implementation of std::replace for ARM64/ARM64EC, enabling vectorization for smaller element sizes where masked stores are available on SVE.
Changes:
- Enable
_VECTORIZED_REPLACEon ARM64/ARM64EC and add 1- and 2-bytereplaceentry points. - Implement SVE-based masked-load/compare/masked-store
__std_replace_{1,2,4,8}invector_algorithms.cpp. - Extend replace benchmarks to include
uint8_tanduint16_t.
Show a summary per file
| File | Description |
|---|---|
| tests/std/tests/VSO_0000000_vector_algorithms/test.cpp | Adjusts which vector algorithm tests are run under the ARM64EC “call all x64” configuration. |
| stl/src/vector_algorithms.cpp | Adds SVE include and introduces SVE-based replace implementations for 1/2/4/8 byte elements on ARM64/ARM64EC. |
| stl/inc/xutility | Enables replace vectorization for ARM64/ARM64EC and introduces _VECTORIZED_REPLACE_1_2. |
| stl/inc/algorithm | Declares new __std_replace_1/2 and updates dispatch/safety logic to allow 1/2-byte vectorized replace on ARM. |
| benchmarks/src/replace.cpp | Adds replace benchmarks for uint8_t and uint16_t. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 2
Member
StephanTLavavej
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR adds an SVE implementation of
replace. This algorithm was previously not vectorized using Neon, due to the absence of masked stores in the instruction set. See #4433 for why this is an issue.Benchmark results ⏲️
Results are speedup values relative to the existing C code as a baseline - higher is better. Benchmark results were obtained running on a Neoverse N2 machine.
r<std::uint8_t>r<std::uint16_t>r<std::uint32_t>r<std::uint64_t>