fitzgen opened PR #5252 from optimize-comparisons-with-immediates-on-aarch64
to main
:
We can encode more constants into 12-bit immediates if we do the following rewrite for comparisons with odd constants:
A >= B + 1 ==> A - 1 >= B ==> A > B
(And similar for less-than-or-equals.)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
fitzgen requested elliottt for a review on PR #5252.
fitzgen created PR review comment:
I'm not sure why these changed here, but also I think it is benign since
movz
is zero-extending the value?
fitzgen submitted PR review.
elliottt submitted PR review.
fitzgen updated PR #5252 from optimize-comparisons-with-immediates-on-aarch64
to main
.
jameysharp submitted PR review.
jameysharp created PR review comment:
Why is
make_imm12_from_u64
separate fromimm12_from_u64
? They look identical to me.
fitzgen created PR review comment:
One is a pure constructor and the other is a fallible extractor. They are identical but can't replace one another in ISLE's type system.
fitzgen submitted PR review.
fitzgen merged PR #5252.
elliottt created PR review comment:
Couldn't it be an infallible extractor? Then there'd be no
Option
in the return type, and the same rust function could be reused for the extractor and constructor in isle.
elliottt submitted PR review.
elliottt created PR review comment:
Scratch that -- I just realized that we're relying on the failure behavior in the extractor case :)
elliottt submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
It can't be infallible because not all
u64
s can be represented withImm12
s
fitzgen edited PR review comment.
jameysharp submitted PR review.
jameysharp created PR review comment:
Ah, I see. But then you could have used the extractor instead of a constructor, right?
(if-let (imm12_from_u64 imm) (u64_sub b 1))
Last updated: Nov 22 2024 at 16:03 UTC