-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AArch64] Improve select dagcombine #169925
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
huntergr-arm
wants to merge
4
commits into
llvm:main
Choose a base branch
from
huntergr-arm:improve-select-combine
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
4 commits
Select commit
Hold shift + click to select a range
1262bd3
[AArch64] Codegen test for select from canonical fixed-width AnyOf
huntergr-arm 7c8b20f
Avoid choosing a bad ElementCount for splatting the condition
huntergr-arm dce36a4
Add suggested wider-than-legal test
huntergr-arm 3be56c0
Always use ResVT's element count before legalization
huntergr-arm 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
Some comments aren't visible on the classic Files Changed page.
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,46 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc %s -o - | FileCheck %s | ||
| target triple = "aarch64-linux-gnu" | ||
|
|
||
| ;; An 'AnyOf' reduction (vector.reduce.or) is instcombined to a bitcast to an | ||
| ;; integer of a bitwidth equal to the number of lanes being reduced, then | ||
| ;; compared against zero. To select between vectors for NEON, we then need to | ||
| ;; broadcast the result, but we must be careful when the bitwidth of the scalar | ||
| ;; result is smaller than the element size of the vectors being selected. We | ||
| ;; don't want to end up with scalarization. | ||
|
|
||
| define <4 x i32> @any_of_select_vf4(<4 x i32> %mask, <4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-LABEL: any_of_select_vf4: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: cmlt v0.4s, v0.4s, #0 | ||
| ; CHECK-NEXT: umaxv s0, v0.4s | ||
| ; CHECK-NEXT: fmov w8, s0 | ||
| ; CHECK-NEXT: tst w8, #0x1 | ||
| ; CHECK-NEXT: csetm w8, ne | ||
| ; CHECK-NEXT: dup v0.4s, w8 | ||
| ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b | ||
| ; CHECK-NEXT: ret | ||
| %cmp = icmp slt <4 x i32> %mask, zeroinitializer | ||
| %cmp.bc = bitcast <4 x i1> %cmp to i4 | ||
| %cmp.bc.not = icmp eq i4 %cmp.bc, 0 | ||
| %res = select i1 %cmp.bc.not, <4 x i32> %a, <4 x i32> %b | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <2 x i64> @any_of_select_vf2(<2 x i64> %mask, <2 x i64> %a, <2 x i64> %b) { | ||
| ; CHECK-LABEL: any_of_select_vf2: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: cmlt v0.2d, v0.2d, #0 | ||
| ; CHECK-NEXT: umaxv s0, v0.4s | ||
| ; CHECK-NEXT: fmov w8, s0 | ||
| ; CHECK-NEXT: tst w8, #0x1 | ||
| ; CHECK-NEXT: csetm x8, ne | ||
| ; CHECK-NEXT: dup v0.2d, x8 | ||
| ; CHECK-NEXT: bsl v0.16b, v2.16b, v1.16b | ||
| ; CHECK-NEXT: ret | ||
| %cmp = icmp slt <2 x i64> %mask, zeroinitializer | ||
| %cmp.bc = bitcast <2 x i1> %cmp to i2 | ||
| %cmp.bc.not = icmp eq i2 %cmp.bc, 0 | ||
| %res = select i1 %cmp.bc.not, <2 x i64> %a, <2 x i64> %b | ||
| ret <2 x i64> %res | ||
| } |
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 would think we always want to use
NumMaskEltsbefore type legalisation, that would also improve e.g.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.
Always using the elementcount of ResVT before legalization does seem to be better, yes. Thanks.