ggreif edited PR #13336.
github-actions[bot] added the label cranelift on PR #13336.
github-actions[bot] added the label cranelift:area:aarch64 on PR #13336.
github-actions[bot] added the label cranelift:area:x64 on PR #13336.
cfallin commented on PR #13336:
Ideally we would do this in the mid-end, not in every back-end individually (and then revert #13334 as well).
In principle this would work by matching on the brif, not the clz -- your mid-end PR only considered simplifications of the clz itself, which is why you didn't see this option I think. In other words, it's not valid to simplify
(clz x)to a barex & 1, but when used as a condition to a brif, where all we are testing is whether the result is nonzero, it is. So the whole(brif (clz x) a b)should simplify to(brif (band x (iconst 1)) a b)more or less (some syntactical details elided).I can't seem to get the
simplify_skeletonentry point to work forbrifright now (quick experiment, I haven't dug into it much); but that's the shape of what we'd want. Does that make sense?
ggreif commented on PR #13336:
Closing in favor of #13343 — the mid-end
simplify_skeleton-on-brifextension covers the same cases and produces strictly better aarch64 code:tbz w0, #0(single-instruction test-and-branch) vs this PR'stst+cmp+b.cc. See the comparison table in #13343.
:cross_mark: ggreif closed without merge PR #13336.
Last updated: Jun 01 2026 at 09:49 UTC