Skip to content

powerpc: Implement vclzlsbb and vctzlsbb - #2266

Merged
folkertdev merged 3 commits into
rust-lang:mainfrom
Gelbpunkt:powerpc-vclzlsbb-vctzlsbb
Nov 15, 2026
Merged

folkertdev merged 3 commits into
rust-lang:mainfrom
Gelbpunkt:powerpc-vclzlsbb-vctzlsbb

Conversation

@Gelbpunkt

Copy link
Copy Markdown
Contributor

The vclzlsbb and vctzlsbb instructions are available on POWER9 and newer with AltiVec enabled. They count the number of leading/trailing bytes in the vector with a LSB of zero.

Clang and GCC both define the vec_cntlz_lsbb and vec_cnttz_lsbb helpers for counting the leading/trailing bytes with LSB of zero in a vector. These then conditionally emit one or the other instruction, depending on endianess. For example, on big endian, vec_cntlz_lsbb emits vclzlsbb, while on little-endian, it emits vctzlsbb. We match that.

@rustbot

rustbot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Amanieu, @adamgemmell, @davidtwco, @folkertdev
  • @Amanieu, @adamgemmell, @davidtwco, @folkertdev expanded to Amanieu, adamgemmell, davidtwco, folkertdev
  • Random selection from Amanieu, adamgemmell, davidtwco, folkertdev

@folkertdev folkertdev closed this Nov 15, 2026
@folkertdev folkertdev reopened this Nov 15, 2026
@folkertdev

Copy link
Copy Markdown
Contributor

Hmm

rustc-LLVM ERROR: Cannot select: intrinsic %llvm.ppc.altivec.vclzlsbb

Some target feature not being set/used right?

@Gelbpunkt
Gelbpunkt force-pushed the powerpc-vclzlsbb-vctzlsbb branch from d19a407 to 2728685 Compare November 15, 2026 17:03
@rustbot

rustbot commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

The vclzlsbb and vctzlsbb instructions are available on POWER9 and newer
with AltiVec enabled. They count the number of leading/trailing bytes in
the vector with a LSB of zero.

Clang and GCC both define the vec_cntlz_lsbb and vec_cnttz_lsbb helpers
for counting the leading/trailing bytes with LSB of zero in a vector.
These then conditionally emit one or the other instruction, depending on
endianess. For example, on big endian, vec_cntlz_lsbb emits vclzlsbb,
while on little-endian, it emits vctzlsbb. We match that.
@Gelbpunkt
Gelbpunkt force-pushed the powerpc-vclzlsbb-vctzlsbb branch from 2728685 to e4ba419 Compare November 15, 2026 17:06
@Gelbpunkt

Copy link
Copy Markdown
Contributor Author

Sorry! Fixed, it now works :)

Comment thread crates/core_arch/src/powerpc/altivec.rs Resolved
@Gelbpunkt
Gelbpunkt force-pushed the powerpc-vclzlsbb-vctzlsbb branch from c02840f to 3f85e3d Compare November 15, 2026 17:45
@folkertdev
folkertdev added this pull request to the merge queue Nov 15, 2026
@folkertdev

Copy link
Copy Markdown
Contributor

Oh for posterity: we could use simd_ctlz and friends here semantically, but currently they are not interchangeable with the platform-specific intrinsics.

Merged via the queue into rust-lang:main with commit 43a9f57 Nov 15, 2026
171 of 173 checks passed
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.

3 participants