shreyasravi320 requested alexcrichton for a review on PR #12644.
shreyasravi320 requested wasmtime-compiler-reviewers for a review on PR #12644.
shreyasravi320 opened PR #12644 from shreyasravi320:cls-impl-x86_64 to bytecodealliance:main:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
Fixes issue #5107
clsimplemented with the identitycls(x) = clz(x ^ (x >> 1)) - 1
All integer types (i8,i16,i32,i64, andi128) handled
Added tests tofiletests
github-actions[bot] added the label cranelift:area:x64 on PR #12644.
github-actions[bot] added the label cranelift on PR #12644.
shreyasravi320 edited PR #12644:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
Fixes #5107
clsimplemented with the identitycls(x) = clz(x ^ (x >> 1)) - 1
All integer types (i8,i16,i32,i64, andi128) handled
Added tests tofiletests
alexcrichton submitted PR review.
alexcrichton created PR review comment:
These two rules can be merged together through the
x64_sarhelper perhaps?
alexcrichton created PR review comment:
For runnable tests we typically use the
runtestdirectory instead ofisa/x64. I see as well there's already acls.cliffile in that directory, so can that file be enabled for x64, and perhaps these tests merged there too?
shreyasravi320 updated PR #12644.
shreyasravi320 submitted PR review.
shreyasravi320 created PR review comment:
Got it. Added x86 support in the cls test there, and added the i128 tests. The existing tests were pretty comprehensive so I just added the i128 tests in the same format.
shreyasravi320 submitted PR review.
shreyasravi320 created PR review comment:
Sounds good. I decided to keep
x64_sarq_miin theclsrule for i128 since it would be more effort to switch that over tox64_sar.
alexcrichton commented on PR #12644:
There's a separate
i128-cls.clifas well which I believe has a specific option to get it to work with s390x. Given all backends now implementclsfor i128 (I think given the test report), want to merge that test intocls.clif? I think adding in theset enable_multi_ret_implicit_sretoption for s390x might fix CI as a side effect too.
shreyasravi320 updated PR #12644.
alexcrichton submitted PR review:
Thanks!
alexcrichton added PR #12644 cranelift/x64: implement cls for all integer types to the merge queue.
alexcrichton merged PR #12644.
alexcrichton removed PR #12644 cranelift/x64: implement cls for all integer types from the merge queue.
Last updated: Mar 23 2026 at 16:19 UTC