Skip to content

Verify optimized brctz - #2383

Merged
miriampolzer merged 7 commits into
mit-plv:masterfrom
klinashka:verify-optimized-brctz
Aug 19, 2026
Merged

Verify optimized brctz#2383
miriampolzer merged 7 commits into
mit-plv:masterfrom
klinashka:verify-optimized-brctz

Conversation

@klinashka

Copy link
Copy Markdown
Contributor

This PR implements an implementation of br_ctz, which takes as input a 64-bit unsigned word and returns the number of trailing Zeros.

The implementation repeatedly shifts the input left by 1, until the input becomes 0. We have opted for this implementation, rather than the more intuitive alternative, because the current implementation targets optimizations performed in the LoopIdiomRecognize pass of the LLVM compiler. This results in efficient compilations by both clang and gcc (even though we did not specifically target gcc initially). More details on this can be found here.

The PR is currently a draft, as it should be merged after mit-plv/coqutil#177 propagates to fiat-crypto.

@klinashka
klinashka marked this pull request as draft August 17, 2026 12:10
@miriampolzer
miriampolzer self-requested a review August 17, 2026 12:15

@miriampolzer miriampolzer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good overall, just some detail comments. Let me know when you rebased and updated so that I can trigger the CI and merge.

Comment thread src/Bedrock/P256/modinv/br_ctz.v Outdated
Comment thread src/Bedrock/P256/modinv/br_ctz.v Outdated
Comment thread src/Bedrock/P256/modinv/br_ctz.v Outdated
Comment thread src/Bedrock/P256/modinv/br_ctz.v Outdated
Comment thread src/Bedrock/P256/modinv/br_ctz.v
@klinashka
klinashka force-pushed the verify-optimized-brctz branch from 3862db6 to 198b31b Compare August 19, 2026 12:23
@klinashka
klinashka requested a review from miriampolzer August 19, 2026 12:27
@klinashka
klinashka marked this pull request as ready for review August 19, 2026 12:27
@klinashka klinashka changed the title [DRAFT] Verify optimized brctz Verify optimized brctz Aug 19, 2026
@miriampolzer
miriampolzer enabled auto-merge (squash) August 19, 2026 14:48
@miriampolzer
miriampolzer merged commit 4f7645d into mit-plv:master Aug 19, 2026
54 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.

2 participants