-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISLE: port fmin, fmax, fmin_pseudo, fmax_pseudo on x64. #3856
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
cranelift
Issues related to the Cranelift code generator
cranelift:area:machinst
Issues related to instruction selection and the new MachInst backend.
cranelift:area:aarch64
Issues related to AArch64 backend.
cranelift:area:x64
Issues related to x64 codegen
isle
Related to the ISLE domain-specific language
labels
Feb 26, 2022
Subscribe to Label Action
This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:machinst", "cranelift:area:x64", "isle"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
fitzgen
approved these changes
Feb 28, 2022
Comment on lines
+2083
to
+2121
;; Compute min(x, y) and min(y, x) with native | ||
;; instructions. These will differ in one of the edge cases | ||
;; above that we have to handle properly. (Conversely, if they | ||
;; don't differ, then the native instruction's answer is the | ||
;; right one per CLIF semantics.) | ||
(let ((min1 Xmm (minps x y)) | ||
(min2 Xmm (minps y x)) | ||
;; Compute the OR of the two. Note that NaNs have an | ||
;; exponent field of all-ones (0xFF for F32), so if either | ||
;; result is a NaN, this OR will be. And if either is a | ||
;; zero (which has an exponent of 0 and mantissa of 0), | ||
;; this captures a sign-bit of 1 (negative) if either | ||
;; input is negative. | ||
;; | ||
;; In the case where we don't have a +/-0 mismatch or | ||
;; NaNs, then `min1` and `min2` are equal and `min_or` is | ||
;; the correct minimum. | ||
(min_or Xmm (orps min1 min2)) | ||
;; "compare unordered" produces a true mask (all ones) in | ||
;; a given lane if the min is a NaN. We use this to | ||
;; generate a mask to ensure quiet NaNs. | ||
(is_nan_mask Xmm (cmpps min_or min2 (FcmpImm.Unordered))) | ||
;; OR in the NaN mask. | ||
(min_or_2 Xmm (orps min_or is_nan_mask)) | ||
;; Shift the NaN mask down so that it covers just the | ||
;; fraction below the NaN signalling bit; we'll use this | ||
;; to mask off non-canonical NaN payloads. | ||
;; | ||
;; All-ones for NaN, shifted down to leave 10 top bits (1 | ||
;; sign, 8 exponent, 1 QNaN bit that must remain set) | ||
;; cleared. | ||
(nan_fraction_mask Xmm (psrld is_nan_mask (RegMemImm.Imm 10))) | ||
;; Do a NAND, so that we retain every bit not set in | ||
;; `nan_fraction_mask`. This mask will be all zeroes (so | ||
;; we retain every bit) in non-NaN cases, and will have | ||
;; ones (so we clear those bits) in NaN-payload bits | ||
;; otherwise. | ||
(final Xmm (andnps nan_fraction_mask min_or_2))) | ||
final)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comments :)
cfallin
force-pushed
the
isle-min-max
branch
from
February 28, 2022 21:29
a5196a4
to
7256d9c
Compare
cfallin
force-pushed
the
isle-min-max
branch
from
February 28, 2022 21:29
7256d9c
to
59454dd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cranelift:area:aarch64
Issues related to AArch64 backend.
cranelift:area:machinst
Issues related to instruction selection and the new MachInst backend.
cranelift:area:x64
Issues related to x64 codegen
cranelift
Issues related to the Cranelift code generator
isle
Related to the ISLE domain-specific language
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The min/max sequences were a bit difficult to wrap my head around, so please let me know if the descriptive comments are inaccurate at all -- I tried to add a bit more detail (e.g. not just "propagate discrepancies" but why the lowering works).
Stacks on top of #3848, #3849, #3855; only last commit is new.