[llvm] d019d05 - [LLVM][CodeGen][AArch64] Add isel for i8/i16 sve.compact intrinsics. (#143139)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 05:10:41 PDT 2025
Author: Paul Walker
Date: 2025-06-10T13:10:38+01:00
New Revision: d019d05ff063dbf12b6288940dd02807d633b721
URL: https://github.com/llvm/llvm-project/commit/d019d05ff063dbf12b6288940dd02807d633b721
DIFF: https://github.com/llvm/llvm-project/commit/d019d05ff063dbf12b6288940dd02807d633b721.diff
LOG: [LLVM][CodeGen][AArch64] Add isel for i8/i16 sve.compact intrinsics. (#143139)
The i8/i16 instruction variants are available for:
* normal functions using sve2p2
* streaming functions using sme2p2
Added:
llvm/test/CodeGen/AArch64/sve2p2-intrinsics.ll
Modified:
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index f4267702906a9..bda1bcf2a730b 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -4499,7 +4499,7 @@ let Predicates = [HasNonStreamingSVE2p2_or_SME2p2] in {
// SVE2 EXPAND
defm EXPAND_ZPZ : sve2_int_perm_expand<"expand">;
// SVE COMPACT - byte and halfword
- defm COMPACT_ZPZ : sve_int_perm_compact_bh<"compact">;
+ defm COMPACT_ZPZ : sve_int_perm_compact_bh<"compact", int_aarch64_sve_compact>;
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index 56d124d0d7581..848b1c30bbeb5 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -7884,9 +7884,14 @@ multiclass sve_int_perm_compact_sd<string asm, SDPatternOperator op> {
def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
}
-multiclass sve_int_perm_compact_bh<string asm> {
+multiclass sve_int_perm_compact_bh<string asm, SDPatternOperator op> {
def _B : sve_int_perm_compact<0b00, asm, ZPR8>;
def _H : sve_int_perm_compact<0b01, asm, ZPR16>;
+
+ def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
+ def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
+ def : SVE_2_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
+ def : SVE_2_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME # _H)>;
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/CodeGen/AArch64/sve2p2-intrinsics.ll b/llvm/test/CodeGen/AArch64/sve2p2-intrinsics.ll
new file mode 100644
index 0000000000000..8d863dab7b47d
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sve2p2-intrinsics.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2p2 < %s | FileCheck %s --check-prefixes=CHECK
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme2p2 -force-streaming < %s | FileCheck %s --check-prefixes=CHECK
+
+;
+; COMPACT
+;
+
+define <vscale x 16 x i8> @compact_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a) {
+; CHECK-LABEL: compact_i8:
+; CHECK: // %bb.0:
+; CHECK-NEXT: compact z0.b, p0, z0.b
+; CHECK-NEXT: ret
+ %out = call <vscale x 16 x i8> @llvm.aarch64.sve.compact.nxv16i8(<vscale x 16 x i1> %pg,
+ <vscale x 16 x i8> %a)
+ ret <vscale x 16 x i8> %out
+}
+
+define <vscale x 8 x i16> @compact_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a) {
+; CHECK-LABEL: compact_i16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: compact z0.h, p0, z0.h
+; CHECK-NEXT: ret
+ %out = call <vscale x 8 x i16> @llvm.aarch64.sve.compact.nxv8i16(<vscale x 8 x i1> %pg,
+ <vscale x 8 x i16> %a)
+ ret <vscale x 8 x i16> %out
+}
+
+define <vscale x 8 x half> @compact_f16(<vscale x 8 x i1> %pg, <vscale x 8 x half> %a) {
+; CHECK-LABEL: compact_f16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: compact z0.h, p0, z0.h
+; CHECK-NEXT: ret
+ %out = call <vscale x 8 x half> @llvm.aarch64.sve.compact.nxv8f16(<vscale x 8 x i1> %pg,
+ <vscale x 8 x half> %a)
+ ret <vscale x 8 x half> %out
+}
+
+define <vscale x 8 x bfloat> @compact_bf16(<vscale x 8 x i1> %pg, <vscale x 8 x bfloat> %a) {
+; CHECK-LABEL: compact_bf16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: compact z0.h, p0, z0.h
+; CHECK-NEXT: ret
+ %out = call <vscale x 8 x bfloat> @llvm.aarch64.sve.compact.nxv8bf16(<vscale x 8 x i1> %pg,
+ <vscale x 8 x bfloat> %a)
+ ret <vscale x 8 x bfloat> %out
+}
+
+declare <vscale x 16 x i8> @llvm.aarch64.sve.compact.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>)
+declare <vscale x 8 x i16> @llvm.aarch64.sve.compact.nxv8i16(<vscale x 8 x i1>, <vscale x 8 x i16>)
+declare <vscale x 8 x half> @llvm.aarch64.sve.compact.nxv8f16(<vscale x 8 x i1>, <vscale x 8 x half>)
+declare <vscale x 8 x bfloat> @llvm.aarch64.sve.compact.nxv8bf16(<vscale x 8 x i1>, <vscale x 8 x bfloat>)
More information about the llvm-commits
mailing list