[llvm] 6865fbd - [AArch64][SME] Use `fmov` instead of NEON `movi` for FP value.
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 01:49:30 PDT 2023
Author: Sander de Smalen
Date: 2023-07-24T08:48:19Z
New Revision: 6865fbd3da94b3bcf46f37222db53b9f1eb2c406
URL: https://github.com/llvm/llvm-project/commit/6865fbd3da94b3bcf46f37222db53b9f1eb2c406
DIFF: https://github.com/llvm/llvm-project/commit/6865fbd3da94b3bcf46f37222db53b9f1eb2c406.diff
LOG: [AArch64][SME] Use `fmov` instead of NEON `movi` for FP value.
NEON `movi` is not valid in Streaming SVE mode, so use an `fmov`
instruction instead for zero-initializing a FP value.
Reviewed By: hassnaa-arm
Differential Revision: https://reviews.llvm.org/D155432
Added:
Modified:
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll
llvm/test/CodeGen/AArch64/sve-streaming-mode-test-register-mov.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 1e9eea63f0573e..76f1cc782b2488 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1330,7 +1330,7 @@ void AArch64AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI) {
void AArch64AsmPrinter::emitFMov0(const MachineInstr &MI) {
Register DestReg = MI.getOperand(0).getReg();
if (STI->hasZeroCycleZeroingFP() && !STI->hasZeroCycleZeroingFPWorkaround() &&
- STI->hasNEON()) {
+ STI->isNeonAvailable()) {
// Convert H/S register to corresponding D register
if (AArch64::H0 <= DestReg && DestReg <= AArch64::H31)
DestReg = AArch64::D0 + (DestReg - AArch64::H0);
diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll
index ca08895b9df276..55ecec520f38f5 100644
--- a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll
+++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll
@@ -195,7 +195,7 @@ define void @store_v1i64(ptr %a) #0 {
define void @store_v1f64(ptr %a) #0 {
; CHECK-LABEL: store_v1f64:
; CHECK: // %bb.0:
-; CHECK-NEXT: movi d0, #0000000000000000
+; CHECK-NEXT: fmov d0, xzr
; CHECK-NEXT: str d0, [x0]
; CHECK-NEXT: ret
store <1 x double> zeroinitializer, ptr %a
diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-test-register-mov.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-test-register-mov.ll
index 5f2c3d77f9a0fd..159a085b05ed09 100644
--- a/llvm/test/CodeGen/AArch64/sve-streaming-mode-test-register-mov.ll
+++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-test-register-mov.ll
@@ -12,4 +12,31 @@ define fp128 @test_streaming_compatible_register_mov(fp128 %q0, fp128 %q1) #0 {
ret fp128 %q1
}
+; Test that `movi` isn't used (invalid in streaming mode), but fmov or SVE mov instead.
+define double @fp_zero_constant() #0 {
+; CHECK-LABEL: fp_zero_constant:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov d0, xzr
+; CHECK-NEXT: ret
+ ret double 0.0
+}
+
+define <2 x i64> @fixed_vec_zero_constant() #0 {
+; CHECK-LABEL: fixed_vec_zero_constant:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z0.d, #0 // =0x0
+; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
+; CHECK-NEXT: ret
+ ret <2 x i64> zeroinitializer
+}
+
+define <2 x double> @fixed_vec_fp_zero_constant() #0 {
+; CHECK-LABEL: fixed_vec_fp_zero_constant:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z0.d, #0 // =0x0
+; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
+; CHECK-NEXT: ret
+ ret <2 x double> <double 0.0, double 0.0>
+}
+
attributes #0 = { "target-features"="+sve" }
More information about the llvm-commits
mailing list