-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[AArch64] Avoid streaming mode hazards from FP constant stores #114207
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
186 changes: 186 additions & 0 deletions
186
llvm/test/CodeGen/AArch64/sve-streaming-mode-fp-constant-stores.ll
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,186 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -aarch64-streaming-hazard-size=64 -force-streaming-compatible -mattr=+sve < %s | FileCheck %s | ||
| ; RUN: llc -aarch64-streaming-hazard-size=64 -force-streaming -mattr=+sme < %s | FileCheck %s | ||
| ; RUN: llc -force-streaming -mattr=+sme < %s | FileCheck %s --check-prefix=NOHAZARD | ||
|
|
||
| target triple = "aarch64-unknown-linux-gnu" | ||
|
|
||
| ; This test checks that in streaming[-compatible] functions if there could be | ||
| ; a hazard between GPR and FPR memory operations, then integer stores are not | ||
| ; used for floating-point constants. | ||
|
|
||
| define void @"store_f64_0.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_f64_0.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: fmov d0, xzr | ||
| ; CHECK-NEXT: str d0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f64_0.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: str xzr, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store double 0.000000e+00, ptr %num, align 8 | ||
MacDue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ret void | ||
| } | ||
|
|
||
| ; (Integer types still use GPR stores) | ||
| define void @store_i64_0(ptr %num) { | ||
| ; CHECK-LABEL: store_i64_0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: str xzr, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_i64_0: | ||
| ; NOHAZARD: // %bb.0: | ||
| ; NOHAZARD-NEXT: str xzr, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| store i64 0, ptr %num, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_f64_1.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_f64_1.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: fmov d0, #1.00000000 | ||
| ; CHECK-NEXT: str d0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f64_1.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: mov x8, #4607182418800017408 // =0x3ff0000000000000 | ||
| ; NOHAZARD-NEXT: str x8, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store double 1.000000e+00, ptr %num, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_f64_1.23456789"(ptr %num) { | ||
| ; CHECK-LABEL: store_f64_1.23456789: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: adrp x8, .LCPI3_0 | ||
| ; CHECK-NEXT: ldr d0, [x8, :lo12:.LCPI3_0] | ||
| ; CHECK-NEXT: str d0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f64_1.23456789: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: mov x8, #56859 // =0xde1b | ||
| ; NOHAZARD-NEXT: movk x8, #17027, lsl #16 | ||
| ; NOHAZARD-NEXT: movk x8, #49354, lsl #32 | ||
| ; NOHAZARD-NEXT: movk x8, #16371, lsl #48 | ||
| ; NOHAZARD-NEXT: str x8, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store double 0x3FF3C0CA4283DE1B, ptr %num, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_f32_0.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_f32_0.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: fmov s0, wzr | ||
| ; CHECK-NEXT: str s0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f32_0.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: str wzr, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store float 0.000000e+00, ptr %num, align 4 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_f32_1.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_f32_1.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: fmov s0, #1.00000000 | ||
| ; CHECK-NEXT: str s0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f32_1.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: mov w8, #1065353216 // =0x3f800000 | ||
| ; NOHAZARD-NEXT: str w8, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store float 1.000000e+00, ptr %num, align 4 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_f32_1.23456789"(ptr %num) { | ||
| ; CHECK-LABEL: store_f32_1.23456789: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: mov w8, #1618 // =0x652 | ||
| ; CHECK-NEXT: movk w8, #16286, lsl #16 | ||
| ; CHECK-NEXT: fmov s0, w8 | ||
| ; CHECK-NEXT: str s0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_f32_1.23456789: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: mov w8, #1618 // =0x652 | ||
| ; NOHAZARD-NEXT: movk w8, #16286, lsl #16 | ||
| ; NOHAZARD-NEXT: str w8, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store float 0x3FF3C0CA40000000, ptr %num, align 4 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_v4f32_0.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_v4f32_0.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: mov z0.s, #0 // =0x0 | ||
| ; CHECK-NEXT: str q0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_v4f32_0.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: stp xzr, xzr, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store <4 x float> zeroinitializer, ptr %num, align 16 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_v4f32_1.0"(ptr %num) { | ||
| ; CHECK-LABEL: store_v4f32_1.0: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: fmov z0.s, #1.00000000 | ||
| ; CHECK-NEXT: str q0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_v4f32_1.0: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: fmov z0.s, #1.00000000 | ||
| ; NOHAZARD-NEXT: str q0, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %num, align 16 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"store_v4f32_1.23456789"(ptr %num) { | ||
| ; CHECK-LABEL: store_v4f32_1.23456789: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: mov w8, #1618 // =0x652 | ||
| ; CHECK-NEXT: movk w8, #16286, lsl #16 | ||
| ; CHECK-NEXT: mov z0.s, w8 | ||
| ; CHECK-NEXT: str q0, [x0] | ||
| ; CHECK-NEXT: ret | ||
| ; | ||
| ; NOHAZARD-LABEL: store_v4f32_1.23456789: | ||
| ; NOHAZARD: // %bb.0: // %entry | ||
| ; NOHAZARD-NEXT: mov w8, #1618 // =0x652 | ||
| ; NOHAZARD-NEXT: movk w8, #16286, lsl #16 | ||
| ; NOHAZARD-NEXT: mov z0.s, w8 | ||
| ; NOHAZARD-NEXT: str q0, [x0] | ||
| ; NOHAZARD-NEXT: ret | ||
| entry: | ||
| store <4 x float> <float 0x3FF3C0CA40000000, float 0x3FF3C0CA40000000, float 0x3FF3C0CA40000000, float 0x3FF3C0CA40000000>, ptr %num, align 16 | ||
| ret void | ||
| } | ||
Oops, something went wrong.
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.
Can you avoid adding a super specific I-want-this-specific-thing-in-one-place style of hook? I would expect this is already expressible in terms of legal operations
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'm not sure it can be, the operations are legal (and the codegen is no different from regular AArch64). The issue is the possible performance impact from accessing the same memory region with FP/vector loads/stores and GPR loads/stores in a streaming SVE function.
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'd like to suggest a better name, but I'm struggling to come up with one. Perhaps you should replace
canbyshouldin the name to make the distinction more clear?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'm not sure... 😅 To me, "can" means you can do something if it's beneficial, which using integer stores for FP constants may be. And "should" means you should always do something, but it's not the case that you should always use integer loads for FP values.
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.
What about creating a
virtual EVT TargetLowering::getPreferredStoreTypeForConstant(SDNode *C) const;that returns an appropriate type? This could then also do the check to see if the integer type is legal, for example.