-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[CodeGen] Implement widening for partial.reduce.add #161834
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
Open
sdesmalen-arm
wants to merge
3
commits into
llvm:main
Choose a base branch
from
sdesmalen-arm:implement-partial-reduce-widening
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | ||
; RUN: llc < %s | FileCheck %s | ||
|
||
target triple = "aarch64" | ||
|
||
define void @partial_reduce_widen_v1i32_acc_v16i32_vec(ptr %accptr, ptr %resptr, ptr %vecptr) { | ||
; CHECK-LABEL: partial_reduce_widen_v1i32_acc_v16i32_vec: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: ldp q1, q0, [x2] | ||
; CHECK-NEXT: ldr s2, [x0] | ||
; CHECK-NEXT: ldp q5, q6, [x2, #32] | ||
; CHECK-NEXT: ext v3.16b, v1.16b, v1.16b, #8 | ||
; CHECK-NEXT: ext v4.16b, v0.16b, v0.16b, #8 | ||
; CHECK-NEXT: add v1.2s, v2.2s, v1.2s | ||
; CHECK-NEXT: ext v2.16b, v5.16b, v5.16b, #8 | ||
; CHECK-NEXT: add v0.2s, v1.2s, v0.2s | ||
; CHECK-NEXT: add v1.2s, v4.2s, v3.2s | ||
; CHECK-NEXT: ext v3.16b, v6.16b, v6.16b, #8 | ||
; CHECK-NEXT: add v0.2s, v0.2s, v5.2s | ||
; CHECK-NEXT: add v1.2s, v2.2s, v1.2s | ||
; CHECK-NEXT: add v0.2s, v0.2s, v6.2s | ||
; CHECK-NEXT: add v1.2s, v3.2s, v1.2s | ||
; CHECK-NEXT: add v0.2s, v1.2s, v0.2s | ||
; CHECK-NEXT: dup v1.2s, v0.s[1] | ||
; CHECK-NEXT: add v0.2s, v0.2s, v1.2s | ||
; CHECK-NEXT: str s0, [x1] | ||
; CHECK-NEXT: ret | ||
%acc = load <1 x i32>, ptr %accptr | ||
%vec = load <16 x i32>, ptr %vecptr | ||
%partial.reduce = call <1 x i32> @llvm.vector.partial.reduce.add(<1 x i32> %acc, <16 x i32> %vec) | ||
store <1 x i32> %partial.reduce, ptr %resptr | ||
ret void | ||
} | ||
|
||
define void @partial_reduce_widen_v3i32_acc_v12i32_vec(ptr %accptr, ptr %resptr, ptr %vecptr) { | ||
; CHECK-LABEL: partial_reduce_widen_v3i32_acc_v12i32_vec: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: sub sp, sp, #128 | ||
; CHECK-NEXT: .cfi_def_cfa_offset 128 | ||
; CHECK-NEXT: ldp q1, q0, [x2] | ||
; CHECK-NEXT: ldr q2, [x0] | ||
; CHECK-NEXT: mov v2.s[3], wzr | ||
; CHECK-NEXT: add v0.4s, v1.4s, v0.4s | ||
; CHECK-NEXT: ldr q1, [x2, #32] | ||
; CHECK-NEXT: add v0.4s, v0.4s, v1.4s | ||
; CHECK-NEXT: add v0.4s, v2.4s, v0.4s | ||
; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8 | ||
; CHECK-NEXT: add v0.2s, v0.2s, v1.2s | ||
; CHECK-NEXT: mov s1, v0.s[2] | ||
; CHECK-NEXT: str d0, [x1] | ||
; CHECK-NEXT: str s1, [x1, #8] | ||
; CHECK-NEXT: add sp, sp, #128 | ||
; CHECK-NEXT: ret | ||
%acc = load <3 x i32>, ptr %accptr | ||
%vec = load <12 x i32>, ptr %vecptr | ||
%partial.reduce = call <3 x i32> @llvm.vector.partial.reduce.add(<3 x i32> %acc, <12 x i32> %vec) | ||
store <3 x i32> %partial.reduce, ptr %resptr | ||
ret void | ||
} | ||
|
||
define void @partial_reduce_widen_v4i32_acc_v20i32_vec(ptr %accptr, ptr %resptr, ptr %vecptr) { | ||
sdesmalen-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
; CHECK-LABEL: partial_reduce_widen_v4i32_acc_v20i32_vec: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: sub sp, sp, #272 | ||
; CHECK-NEXT: str x29, [sp, #256] // 8-byte Folded Spill | ||
; CHECK-NEXT: .cfi_def_cfa_offset 272 | ||
; CHECK-NEXT: .cfi_offset w29, -16 | ||
; CHECK-NEXT: ldp q1, q0, [x2] | ||
; CHECK-NEXT: ldr s2, [x0] | ||
; CHECK-NEXT: ldp q5, q6, [x2, #32] | ||
; CHECK-NEXT: ldr x29, [sp, #256] // 8-byte Folded Reload | ||
; CHECK-NEXT: ext v3.16b, v1.16b, v1.16b, #8 | ||
; CHECK-NEXT: ext v4.16b, v0.16b, v0.16b, #8 | ||
; CHECK-NEXT: add v1.2s, v2.2s, v1.2s | ||
; CHECK-NEXT: ext v2.16b, v5.16b, v5.16b, #8 | ||
; CHECK-NEXT: add v0.2s, v1.2s, v0.2s | ||
; CHECK-NEXT: add v1.2s, v4.2s, v3.2s | ||
; CHECK-NEXT: ext v3.16b, v6.16b, v6.16b, #8 | ||
; CHECK-NEXT: ldr q4, [x2, #64] | ||
; CHECK-NEXT: add v0.2s, v0.2s, v5.2s | ||
; CHECK-NEXT: add v1.2s, v2.2s, v1.2s | ||
; CHECK-NEXT: ext v2.16b, v4.16b, v4.16b, #8 | ||
; CHECK-NEXT: add v0.2s, v0.2s, v6.2s | ||
; CHECK-NEXT: add v1.2s, v3.2s, v1.2s | ||
; CHECK-NEXT: add v0.2s, v0.2s, v4.2s | ||
; CHECK-NEXT: add v1.2s, v2.2s, v1.2s | ||
; CHECK-NEXT: add v0.2s, v1.2s, v0.2s | ||
; CHECK-NEXT: dup v1.2s, v0.s[1] | ||
; CHECK-NEXT: add v0.2s, v0.2s, v1.2s | ||
; CHECK-NEXT: str s0, [x1] | ||
; CHECK-NEXT: add sp, sp, #272 | ||
; CHECK-NEXT: ret | ||
%acc = load <1 x i32>, ptr %accptr | ||
%vec = load <20 x i32>, ptr %vecptr | ||
%partial.reduce = call <1 x i32> @llvm.vector.partial.reduce.add(<1 x i32> %acc, <20 x i32> %vec) | ||
store <1 x i32> %partial.reduce, ptr %resptr | ||
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.
Could these tests just take the vectors as parameters and return the vector 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.
The reason I didn't do that was so that I wouldn't have to pass/return illegal types to the function (the ABI only describes how legal types are passed)
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.
That makes sense 👍