-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AArch64] Avoid GPR trip when moving truncated i32 vector elements #114541
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
SpencerAbson
merged 10 commits into
llvm:main
from
SpencerAbson:use-ins-for-truncated-mov
Dec 20, 2024
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5cd15cb
[AArch64] Avoid GPR trip when moving truncated i32 vector elements
SpencerAbson cb225b4
[NFC] Remove unused node operator
SpencerAbson d25df8c
[NFC] Add negative tests for bound of SVE extraction
SpencerAbson a8c6043
Implement DAG combine for truncating extracted i64
SpencerAbson 0d76f39
[NFC] Refactor DUP patterns
SpencerAbson 0534b1e
Fixup and restrict combine where the extracted element has other uses
SpencerAbson b245dfd
[NFC] clang-format
SpencerAbson c830d92
[NFC] Fixups from review
SpencerAbson 6a4ce54
Merge branch 'main' into use-ins-for-truncated-mov
SpencerAbson ef7431c
Update vecreduce-bool test
SpencerAbson 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,136 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+neon < %s | FileCheck %s | ||
|
|
||
| ; Inserting a truncated (i64 to i32) element from the bottom 128-bits of any vector type into a NEON vector should use INS (element) of the | ||
| ; truncated size to avoid pointless GPR trips. | ||
|
|
||
|
|
||
| define <2 x i32> @test_s_trunc_d_lane0(<2 x i32> %a, <1 x i64> %b) { | ||
| ; CHECK-LABEL: test_s_trunc_d_lane0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 | ||
| ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1 | ||
| ; CHECK-NEXT: mov v0.s[0], v1.s[0] | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <1 x i64> %b, i32 0 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <2 x i32> %a, i32 %d, i64 0 | ||
| ret <2 x i32> %e | ||
| } | ||
|
|
||
| define <2 x i32> @test_s_trunc_d_qlane1(<2 x i32> %a, <2 x i64> %b) { | ||
| ; CHECK-LABEL: test_s_trunc_d_qlane1: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 | ||
| ; CHECK-NEXT: mov v0.s[0], v1.s[2] | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <2 x i64> %b, i32 1 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <2 x i32> %a, i32 %d, i64 0 | ||
| ret <2 x i32> %e | ||
| } | ||
|
|
||
| define <4 x i32> @test_qs_trunc_d_lane0(<4 x i32> %a, <1 x i64> %b) { | ||
| ; CHECK-LABEL: test_qs_trunc_d_lane0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1 | ||
| ; CHECK-NEXT: mov v0.s[0], v1.s[0] | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <1 x i64> %b, i32 0 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <4 x i32> %a, i32 %d, i64 0 | ||
| ret <4 x i32> %e | ||
| } | ||
|
|
||
| define <4 x i32> @test_qs_trunc_d_qlane1(<4 x i32> %a, <2 x i64> %b) { | ||
| ; CHECK-LABEL: test_qs_trunc_d_qlane1: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov v0.s[3], v1.s[2] | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <2 x i64> %b, i32 1 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <4 x i32> %a, i32 %d, i64 3 | ||
| ret <4 x i32> %e | ||
| } | ||
|
|
||
| ; ---- From the bottom 128b of an SVE vector | ||
|
|
||
| define <2 x i32> @test_s_trunc_dsve_lane0(<2 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_s_trunc_dsve_lane0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 | ||
| ; CHECK-NEXT: mov v0.s[0], v1.s[0] | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 0 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <2 x i32> %a, i32 %d, i64 0 | ||
| ret <2 x i32> %e | ||
| } | ||
|
|
||
| define <2 x i32> @test_s_trunc_dsve_lane1(<2 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_s_trunc_dsve_lane1: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 | ||
| ; CHECK-NEXT: mov v0.s[1], v1.s[2] | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 1 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <2 x i32> %a, i32 %d, i64 1 | ||
| ret <2 x i32> %e | ||
| } | ||
|
|
||
| ; (negative test) Extracted element is not within V-register. | ||
| define <2 x i32> @test_s_trunc_dsve_lane2(<2 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_s_trunc_dsve_lane2: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov z1.s, z1.s[4] | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0 | ||
| ; CHECK-NEXT: fmov w8, s1 | ||
| ; CHECK-NEXT: mov v0.s[1], w8 | ||
| ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 2 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <2 x i32> %a, i32 %d, i64 1 | ||
| ret <2 x i32> %e | ||
| } | ||
|
|
||
| define <4 x i32> @test_qs_trunc_dsve_lane0(<4 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_qs_trunc_dsve_lane0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov v0.s[0], v1.s[0] | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 0 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <4 x i32> %a, i32 %d, i64 0 | ||
| ret <4 x i32> %e | ||
| } | ||
|
|
||
| define <4 x i32> @test_qs_trunc_dsve_lane1(<4 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_qs_trunc_dsve_lane1: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov v0.s[3], v1.s[2] | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 1 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <4 x i32> %a, i32 %d, i64 3 | ||
| ret <4 x i32> %e | ||
| } | ||
|
|
||
| ; (negative test) Extracted element is not within V-register. | ||
| define <4 x i32> @test_qs_trunc_dsve_lane2(<4 x i32> %a, <vscale x 2 x i64> %b) { | ||
| ; CHECK-LABEL: test_qs_trunc_dsve_lane2: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov z1.s, z1.s[4] | ||
| ; CHECK-NEXT: fmov w8, s1 | ||
| ; CHECK-NEXT: mov v0.s[3], w8 | ||
| ; CHECK-NEXT: ret | ||
| %c = extractelement <vscale x 2 x i64> %b, i32 2 | ||
| %d = trunc i64 %c to i32 | ||
| %e = insertelement <4 x i32> %a, i32 %d, i64 3 | ||
| ret <4 x i32> %e | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.