-
Notifications
You must be signed in to change notification settings - Fork 1.7k
aarch64: Add support for the fmls instruction
#5895
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| test compile precise-output | ||
| target aarch64 | ||
|
|
||
| function %fma_f32(f32, f32, f32) -> f32 { | ||
| block0(v0: f32, v1: f32, v2: f32): | ||
| v3 = fma v0, v1, v2 | ||
| return v3 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; fmadd s0, s0, s1, s2 | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; fmadd s0, s0, s1, s2 | ||
| ; ret | ||
|
|
||
| function %fma_f64(f64, f64, f64) -> f64 { | ||
| block0(v0: f64, v1: f64, v2: f64): | ||
| v3 = fma v0, v1, v2 | ||
| return v3 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; fmadd d0, d0, d1, d2 | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; fmadd d0, d0, d1, d2 | ||
| ; ret | ||
|
|
||
| function %fma_f32x4(f32x4, f32x4, f32x4) -> f32x4 { | ||
| block0(v0: f32x4, v1: f32x4, v2: f32x4): | ||
| v3 = fma v0, v1, v2 | ||
| return v3 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmla v0.4s, v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmla v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
|
|
||
| function %fma_f64x2(f64x2, f64x2, f64x2) -> f64x2 { | ||
| block0(v0: f64x2, v1: f64x2, v2: f64x2): | ||
| v3 = fma v0, v1, v2 | ||
| return v3 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmla v0.2d, v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmla v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
|
|
||
| function %fma_neg_f32x4(f32x4, f32x4, f32x4) -> f32x4 { | ||
| block0(v0: f32x4, v1: f32x4, v2: f32x4): | ||
| v3 = fneg v0 | ||
| v4 = fma v3, v1, v2 | ||
| return v4 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.4s, v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
|
|
||
| function %fma_neg_f64x2(f64x2, f64x2, f64x2) -> f64x2 { | ||
| block0(v0: f64x2, v1: f64x2, v2: f64x2): | ||
| v3 = fneg v0 | ||
| v4 = fma v3, v1, v2 | ||
| return v4 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.2d, v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
|
|
||
| function %fma_neg_other_f32x4(f32x4, f32x4, f32x4) -> f32x4 { | ||
| block0(v0: f32x4, v1: f32x4, v2: f32x4): | ||
| v3 = fneg v1 | ||
| v4 = fma v0, v3, v2 | ||
| return v4 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.4s, v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.4s, v5.4s, v1.4s | ||
| ; ret | ||
|
|
||
| function %fma_neg_other_f64x2(f64x2, f64x2, f64x2) -> f64x2 { | ||
| block0(v0: f64x2, v1: f64x2, v2: f64x2): | ||
| v3 = fneg v1 | ||
| v4 = fma v0, v3, v2 | ||
| return v4 | ||
| } | ||
|
|
||
| ; VCode: | ||
| ; block0: | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.2d, v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
| ; | ||
| ; Disassembled: | ||
| ; block0: ; offset 0x0 | ||
| ; mov v5.16b, v0.16b | ||
| ; mov v0.16b, v2.16b | ||
| ; fmls v0.2d, v5.2d, v1.2d | ||
| ; ret | ||
|
|
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.
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.
I suppose if both
xandyarefnegthen this can emitfmlainstead offneg+fmls, right? But I guess that's a rewrite we ought to do in the egraph optimizations instead.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.
Indeed! The x64 rules actually end up implementing that (they enable sort of switching back and forth given their structure) but it wasn't as obvious to do here - x64 uses a helper that manages sinking a load as well which adds a fair number of permutations.
I'll send a follow-up which implements the egraph optimization.