Skip to content

cranelift/x64: implement cls for all integer types#12644

Merged
alexcrichton merged 3 commits intobytecodealliance:mainfrom
shreyasravi320:cls-impl-x86_64
Feb 25, 2026
Merged

cranelift/x64: implement cls for all integer types#12644
alexcrichton merged 3 commits intobytecodealliance:mainfrom
shreyasravi320:cls-impl-x86_64

Conversation

@shreyasravi320
Copy link
Copy Markdown
Contributor

@shreyasravi320 shreyasravi320 commented Feb 24, 2026

Fixes #5107
cls implemented with the identity cls(x) = clz(x ^ (x >> 1)) - 1
All integer types (i8, i16, i32, i64, and i128) handled
Added tests to filetests

@shreyasravi320 shreyasravi320 requested a review from a team as a code owner February 24, 2026 03:35
@shreyasravi320 shreyasravi320 requested review from alexcrichton and removed request for a team February 24, 2026 03:35
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels Feb 24, 2026
@alexcrichton
Copy link
Copy Markdown
Member

There's a separate i128-cls.clif as well which I believe has a specific option to get it to work with s390x. Given all backends now implement cls for i128 (I think given the test report), want to merge that test into cls.clif? I think adding in the set enable_multi_ret_implicit_sret option for s390x might fix CI as a side effect too.

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

@alexcrichton alexcrichton added this pull request to the merge queue Feb 25, 2026
Merged via the queue into bytecodealliance:main with commit 9dc1564 Feb 25, 2026
76 checks passed
@shreyasravi320 shreyasravi320 deleted the cls-impl-x86_64 branch February 25, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cranelift: cls not implemented for any type on x86_64

2 participants