Skip to content

Conversation

@anvacaru
Copy link
Contributor

blocked on: #2823

Implementing the CLZ (Counting Leading Zeros) opcode introduced in EIP-7939.

The opcode returns the number of leading zeros in an evm word. There is a special case for 0, in which the returned value is 256. It has a gas cost of five, similar to the other Wlow opcodes, and is available from the Osaka schedule onwards.

To compute the number of leading zeros of a number, we use the log2Int K builtin, as it returns the index of the highest set bit, which we then subtract from 255.

@anvacaru anvacaru marked this pull request as ready for review December 15, 2025 17:04
@anvacaru anvacaru self-assigned this Dec 15, 2025
@anvacaru anvacaru requested a review from ehildenb December 15, 2025 17:04
@anvacaru anvacaru merged commit e128e47 into master Dec 15, 2025
12 checks passed
@anvacaru anvacaru deleted the eip-7939 branch December 15, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants