-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LoongArch] Codegen for concat_vectors with LASX #107523
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
wangleiat
merged 1 commit into
main
from
users/wangleiat/spr/loongarch-codegen-for-concat_vectors-with-lasx
Sep 10, 2024
Merged
[LoongArch] Codegen for concat_vectors with LASX #107523
wangleiat
merged 1 commit into
main
from
users/wangleiat/spr/loongarch-codegen-for-concat_vectors-with-lasx
Sep 10, 2024
Conversation
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
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-backend-loongarch Author: wanglei (wangleiat) ChangesFixes: #107355 Full diff: https://github.com/llvm/llvm-project/pull/107523.diff 3 Files Affected:
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 95c1b150722f64..5ed1dd897e7447 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -296,6 +296,7 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::INSERT_VECTOR_ELT, VT, Custom);
setOperationAction(ISD::EXTRACT_VECTOR_ELT, VT, Custom);
setOperationAction(ISD::BUILD_VECTOR, VT, Custom);
+ setOperationAction(ISD::CONCAT_VECTORS, VT, Legal);
setOperationAction(ISD::SETCC, VT, Legal);
setOperationAction(ISD::VSELECT, VT, Legal);
diff --git a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
index 6d6317ea35e35f..dd7e5713e45fe9 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -1789,6 +1789,12 @@ def : Pat<(v4i32 (fp_to_uint (v4f64 LASX256:$vj))),
v4f64:$vj)),
sub_128)>;
+// XVPERMI_Q
+foreach vt = [v32i8, v16i16, v8i32, v4i64, v8f32, v4f64] in
+def : Pat<(vt (concat_vectors LSX128:$vd, LSX128:$vj)),
+ (XVPERMI_Q (SUBREG_TO_REG (i64 0), LSX128:$vd, sub_128),
+ (SUBREG_TO_REG (i64 0), LSX128:$vj, sub_128), 2)>;
+
} // Predicates = [HasExtLASX]
/// Intrinsic pattern
diff --git a/llvm/test/CodeGen/LoongArch/lasx/issue107355.ll b/llvm/test/CodeGen/LoongArch/lasx/issue107355.ll
new file mode 100644
index 00000000000000..818bd4311615d3
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/lasx/issue107355.ll
@@ -0,0 +1,35 @@
+; 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
+
+;; Without this patch(codegen for concat_vectors), the test will hang.
+@g_156 = external global [12 x i32]
+@g_490 = external global i32
+@g_813 = external global i32
+
+define void @foo() {
+; CHECK-LABEL: foo:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: pcalau12i $a0, %got_pc_hi20(g_156)
+; CHECK-NEXT: ld.d $a0, $a0, %got_pc_lo12(g_156)
+; CHECK-NEXT: pcalau12i $a1, %got_pc_hi20(g_490)
+; CHECK-NEXT: ld.d $a1, $a1, %got_pc_lo12(g_490)
+; CHECK-NEXT: ld.w $a2, $a0, 24
+; CHECK-NEXT: pcalau12i $a3, %got_pc_hi20(g_813)
+; CHECK-NEXT: ld.d $a3, $a3, %got_pc_lo12(g_813)
+; CHECK-NEXT: st.w $zero, $a1, 0
+; CHECK-NEXT: st.w $a2, $a3, 0
+; CHECK-NEXT: vrepli.b $vr0, 0
+; CHECK-NEXT: vst $vr0, $a0, 32
+; CHECK-NEXT: xvpermi.q $xr0, $xr0, 2
+; CHECK-NEXT: xvst $xr0, $a0, 0
+; CHECK-NEXT: st.w $zero, $a0, 20
+; CHECK-NEXT: ret
+entry:
+ store i32 0, ptr getelementptr inbounds (i8, ptr @g_156, i64 20), align 4
+ store i32 0, ptr @g_490, align 4
+ %0 = load i32, ptr getelementptr inbounds (i8, ptr @g_156, i64 24), align 4
+ store i32 %0, ptr @g_813, align 4
+ tail call void @llvm.memset.p0.i64(ptr @g_156, i8 0, i64 48, i1 false)
+ store i32 0, ptr getelementptr inbounds (i8, ptr @g_156, i64 20), align 4
+ ret void
+}
|
SixWeining
approved these changes
Sep 9, 2024
/cherry-pick 1ca411c |
llvmbot
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Sep 10, 2024
Fixes: llvm#107355 Reviewed By: SixWeining Pull Request: llvm#107523 (cherry picked from commit 1ca411c)
/pull-request #107948 |
tru
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Sep 24, 2024
Fixes: llvm#107355 Reviewed By: SixWeining Pull Request: llvm#107523 (cherry picked from commit 1ca411c)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #107355