-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
riscv64: Improve pattern matching rules for FMA #8596
Conversation
This commit reworks our FMA pattern matching to be slightly less verbose. It additionally adds the `(fma x (splat y) z)` pattern for vectors, which can be proven to be equivalent to `(splat x)`. Co-Authored-By: Jamey Sharp <[email protected]>
Redirecting to @jameysharp since it seems like he has more context here. |
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.
Fantastic, I love that this worked out, and I really appreciate the effort you put into using Alive2 to check which of my guesses were correct. Too bad about signed zeroes…
By the way, this motivated me to write up #8599, which would make this kind of pattern easier to write someday.
(rule 1 (is_fneg (fneg x)) (IsFneg.Result 1 x)) | ||
(rule 0 (is_fneg x) (IsFneg.Result 0 x)) | ||
|
||
(rule 1 (lower (has_type ty (fma x_src y_src z_src))) |
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.
Interesting, why does this rule need a priority?
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.
Oops, it shouldn't. I was debugging some stuff and forgot to remove it.
👋 Hey,
This PR reworks our FMA pattern matching to be slightly less verbose using the suggestions provided by @jameysharp on #8588 (comment).
It additionally adds the
(fma x (splat y) z)
pattern for vectors, which can be proven to be equivalent to(fma y (splat x) z)
. See #8588 (comment). I've only added ISA tests for these patterns since it turns out they are already present in the SIMD FMA runtests.I think all of the patterns matched here are sound although I can't formally prove all of them. This comment #8588 (comment) describes most of the validations that I did.