[llvm] e9c8973 - [AArch64][SME] Fix v8.6a bf16 NEON instruction predication

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 01:37:17 PDT 2021


Author: Cullen Rhodes
Date: 2021-08-24T08:13:57Z
New Revision: e9c8973f1c6879a4545329afceb66cc98447574f

URL: https://github.com/llvm/llvm-project/commit/e9c8973f1c6879a4545329afceb66cc98447574f
DIFF: https://github.com/llvm/llvm-project/commit/e9c8973f1c6879a4545329afceb66cc98447574f.diff

LOG: [AArch64][SME] Fix v8.6a bf16 NEON instruction predication

In streaming mode on SME targets only the scalar BFCVT armv8.6-a
instruction is legal, predicate the illegal instructions on NEON to
disable them in streaming mode (see D107902). BFCVT is predicated on
HasNEONorStreamingSVE.

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-06/SIMD-FP-Instructions

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D108279

Added: 
    llvm/test/MC/AArch64/SME/streaming-mode-neon-bf16.s

Modified: 
    llvm/lib/Target/AArch64/AArch64InstrInfo.td
    llvm/test/MC/AArch64/SME/streaming-mode-neon-negative.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 79a35246615f2..990ae3eef654a 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -873,7 +873,7 @@ defm UDOTlane : SIMDThreeSameVectorDotIndex<1, 0, 0b10, "udot", AArch64udot>;
 }
 
 // ARMv8.6-A BFloat
-let Predicates = [HasBF16] in {
+let Predicates = [HasNEON, HasBF16] in {
 defm BFDOT       : SIMDThreeSameVectorBFDot<1, "bfdot">;
 defm BF16DOTlane : SIMDThreeSameVectorBF16DotI<0, "bfdot">;
 def BFMMLA       : SIMDThreeSameVectorBF16MatrixMul<"bfmmla">;
@@ -883,7 +883,6 @@ def BFMLALBIdx   : SIMDBF16MLALIndex<0, "bfmlalb", int_aarch64_neon_bfmlalb>;
 def BFMLALTIdx   : SIMDBF16MLALIndex<1, "bfmlalt", int_aarch64_neon_bfmlalt>;
 def BFCVTN       : SIMD_BFCVTN;
 def BFCVTN2      : SIMD_BFCVTN2;
-def BFCVT        : BF16ToSinglePrecision<"bfcvt">;
 
 // Vector-scalar BFDOT:
 // The second source operand of the 64-bit variant of BF16DOTlane is a 128-bit
@@ -903,6 +902,10 @@ def : Pat<(v2f32 (int_aarch64_neon_bfdot
                              VectorIndexS:$idx)>;
 }
 
+let Predicates = [HasNEONorStreamingSVE, HasBF16] in {
+def BFCVT : BF16ToSinglePrecision<"bfcvt">;
+}
+
 // ARMv8.6A AArch64 matrix multiplication
 let Predicates = [HasMatMulInt8] in {
 def  SMMLA : SIMDThreeSameVectorMatMul<0, 0, "smmla", int_aarch64_neon_smmla>;

diff  --git a/llvm/test/MC/AArch64/SME/streaming-mode-neon-bf16.s b/llvm/test/MC/AArch64/SME/streaming-mode-neon-bf16.s
new file mode 100644
index 0000000000000..d0733e1499657
--- /dev/null
+++ b/llvm/test/MC/AArch64/SME/streaming-mode-neon-bf16.s
@@ -0,0 +1,16 @@
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+streaming-sve,+bf16 < %s \
+// RUN:        | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=-neon < %s 2>&1 \
+// RUN:        | FileCheck %s --check-prefix=CHECK-ERROR
+// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+streaming-sve,+bf16 < %s \
+// RUN:        | llvm-objdump --mattr=+bf16 -d - | FileCheck %s --check-prefix=CHECK-INST
+// Disassemble encoding and check the re-encoding (-show-encoding) matches.
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+streaming-sve,+bf16 < %s \
+// RUN:        | sed '/.text/d' | sed 's/.*encoding: //g' \
+// RUN:        | llvm-mc -triple=aarch64 -mattr=+streaming-sve,+bf16 -disassemble -show-encoding \
+// RUN:        | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+
+bfcvt h5, s3
+// CHECK-INST: bfcvt h5, s3
+// CHECK-ENCODING: [0x65,0x40,0x63,0x1e]
+// CHECK-ERROR: instruction requires: bf16

diff  --git a/llvm/test/MC/AArch64/SME/streaming-mode-neon-negative.s b/llvm/test/MC/AArch64/SME/streaming-mode-neon-negative.s
index d700c9217611d..25762b43c7ce2 100644
--- a/llvm/test/MC/AArch64/SME/streaming-mode-neon-negative.s
+++ b/llvm/test/MC/AArch64/SME/streaming-mode-neon-negative.s
@@ -1,4 +1,4 @@
-// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+streaming-sve 2>&1 < %s| FileCheck %s
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+streaming-sve,+bf16 2>&1 < %s| FileCheck %s
 
 // ------------------------------------------------------------------------- //
 // Check FABD is illegal in streaming mode
@@ -7,3 +7,11 @@ fabd s0, s1, s2
 // CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: neon
 // CHECK-NEXT: fabd s0, s1, s2
 // CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+// ------------------------------------------------------------------------- //
+// Check non-scalar v8.6a BFloat16 instructions are illegal in streaming mode
+
+bfcvtn v5.4h, v5.4s
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: neon
+// CHECK-NEXT: bfcvtn v5.4h, v5.4s
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:


        


More information about the llvm-commits mailing list