-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[LoongArch] Optimize 128-to-256-bit vector insertion and 256-to-128-bit subvector extraction #146300
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
heiher
wants to merge
2
commits into
llvm:main
Choose a base branch
from
heiher:opt-vec-128-256
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.
+989
−9
Open
[LoongArch] Optimize 128-to-256-bit vector insertion and 256-to-128-bit subvector extraction #146300
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s | ||
|
||
define <32 x i8> @concat_poison_v32i8_1(<16 x i8> %a) { | ||
; CHECK-LABEL: concat_poison_v32i8_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <16 x i8> %a, <16 x i8> poison, | ||
<32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, | ||
i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, | ||
i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31> | ||
ret <32 x i8> %1 | ||
} | ||
|
||
define <32 x i8> @concat_poison_v32i8_2(<16 x i8> %a, <16 x i8> %b) { | ||
; CHECK-LABEL: concat_poison_v32i8_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <16 x i8> %b, <16 x i8> poison, | ||
<32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, | ||
i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, | ||
i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31> | ||
ret <32 x i8> %1 | ||
} | ||
|
||
define <32 x i8> @concat_vectors_v32i8(<16 x i8> %a, <16 x i8> %b) { | ||
; CHECK-LABEL: concat_vectors_v32i8: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <16 x i8> %a, <16 x i8> %b, | ||
<32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, | ||
i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, | ||
i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31> | ||
ret <32 x i8> %1 | ||
} | ||
|
||
define <16 x i16> @concat_poison_v16i16_1(<8 x i16> %a) { | ||
; CHECK-LABEL: concat_poison_v16i16_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <8 x i16> %a, <8 x i16> poison, | ||
<16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
ret <16 x i16> %1 | ||
} | ||
|
||
define <16 x i16> @concat_poison_v16i16_2(<8 x i16> %a, <8 x i16> %b) { | ||
; CHECK-LABEL: concat_poison_v16i16_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <8 x i16> %b, <8 x i16> poison, | ||
<16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
ret <16 x i16> %1 | ||
} | ||
|
||
define <16 x i16> @concat_vectors_v16i16(<8 x i16> %a, <8 x i16> %b) { | ||
; CHECK-LABEL: concat_vectors_v16i16: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <8 x i16> %a, <8 x i16> %b, | ||
<16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, | ||
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
ret <16 x i16> %1 | ||
} | ||
|
||
define <8 x i32> @concat_poison_v8i32_1(<4 x i32> %a) { | ||
; CHECK-LABEL: concat_poison_v8i32_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x i32> %a, <4 x i32> poison, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x i32> %1 | ||
} | ||
|
||
define <8 x i32> @concat_poison_v8i32_2(<4 x i32> %a, <4 x i32> %b) { | ||
; CHECK-LABEL: concat_poison_v8i32_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x i32> %b, <4 x i32> poison, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x i32> %1 | ||
} | ||
|
||
define <8 x i32> @concat_vectors_v8i32(<4 x i32> %a, <4 x i32> %b) { | ||
; CHECK-LABEL: concat_vectors_v8i32: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x i32> %a, <4 x i32> %b, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x i32> %1 | ||
} | ||
|
||
define <8 x float> @concat_poison_v8f32_1(<4 x float> %a) { | ||
; CHECK-LABEL: concat_poison_v8f32_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x float> %a, <4 x float> poison, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x float> %1 | ||
} | ||
|
||
define <8 x float> @concat_poison_v8f32_2(<4 x float> %a, <4 x float> %b) { | ||
; CHECK-LABEL: concat_poison_v8f32_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x float> %b, <4 x float> poison, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x float> %1 | ||
} | ||
|
||
define <8 x float> @concat_vectors_v8f32(<4 x float> %a, <4 x float> %b) { | ||
; CHECK-LABEL: concat_vectors_v8f32: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <4 x float> %a, <4 x float> %b, | ||
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
ret <8 x float> %1 | ||
} | ||
|
||
define <4 x i64> @concat_poison_v8i64_1(<2 x i64> %a) { | ||
; CHECK-LABEL: concat_poison_v8i64_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x i64> %a, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x i64> %1 | ||
} | ||
|
||
define <4 x i64> @concat_poison_v8i64_2(<2 x i64> %a, <2 x i64> %b) { | ||
; CHECK-LABEL: concat_poison_v8i64_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x i64> %b, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x i64> %1 | ||
} | ||
|
||
define <4 x i64> @concat_vectors_v8i64(<2 x i64> %a, <2 x i64> %b) { | ||
; CHECK-LABEL: concat_vectors_v8i64: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x i64> %a, <2 x i64> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x i64> %1 | ||
} | ||
|
||
define <4 x double> @concat_poison_v8f64_1(<2 x double> %a) { | ||
; CHECK-LABEL: concat_poison_v8f64_1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x double> %a, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x double> %1 | ||
} | ||
|
||
define <4 x double> @concat_poison_v8f64_2(<2 x double> %a, <2 x double> %b) { | ||
; CHECK-LABEL: concat_poison_v8f64_2: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: vori.b $vr0, $vr1, 0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x double> %b, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x double> %1 | ||
} | ||
|
||
define <4 x double> @concat_vectors_v8f64(<2 x double> %a, <2 x double> %b) { | ||
; CHECK-LABEL: concat_vectors_v8f64: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: # kill: def $vr1 killed $vr1 def $xr1 | ||
; CHECK-NEXT: # kill: def $vr0 killed $vr0 def $xr0 | ||
; CHECK-NEXT: xvpermi.q $xr0, $xr1, 2 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%1 = shufflevector <2 x double> %a, <2 x double> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 3> | ||
ret <4 x double> %1 | ||
} |
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.
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.
xvpermi.q $xd, $xj 1
would change the$xj
register ifxj == xd
And many cases show this change.
e.g. tangaac/loong-opt-cov-ts@c0576ea#diff-364b3817b5e53b0b599b12041f8b1377a5d7c6f473fa5d3c75db971e939debb5L2105-R2165
We could use
xvpermi.d $xd, $xj, 14
to avoid this.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.
If the output operand and an input operand are assigned the same physical register, does that mean the input operand's live range has ended?
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.
Yes