[llvm] c8b4460 - [AArch64] Avoid emitting MOVID when NEON is disabled
Alex Richardson via llvm-commits
llvm-commits at lists.llvm.org
Sat May 14 07:43:30 PDT 2022
Author: Alex Richardson
Date: 2022-05-14T14:40:51Z
New Revision: c8b44600c5ec358fe5d5eeb1f3c83c8e435b94e3
URL: https://github.com/llvm/llvm-project/commit/c8b44600c5ec358fe5d5eeb1f3c83c8e435b94e3
DIFF: https://github.com/llvm/llvm-project/commit/c8b44600c5ec358fe5d5eeb1f3c83c8e435b94e3.diff
LOG: [AArch64] Avoid emitting MOVID when NEON is disabled
Previously, creating a zero floating-point constant used MOVID even when
NEON was disabled which resulted in the following fatal error:
`Attempting to emit MOVID instruction but the Feature_HasNEON predicate(s) are not met`
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D125237
Added:
llvm/test/CodeGen/AArch64/movid-no-neon.ll
Modified:
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index b54a0eaba7d1..de71c9318948 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -1129,7 +1129,8 @@ void AArch64AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI) {
void AArch64AsmPrinter::emitFMov0(const MachineInstr &MI) {
Register DestReg = MI.getOperand(0).getReg();
- if (STI->hasZeroCycleZeroingFP() && !STI->hasZeroCycleZeroingFPWorkaround()) {
+ if (STI->hasZeroCycleZeroingFP() && !STI->hasZeroCycleZeroingFPWorkaround() &&
+ STI->hasNEON()) {
// 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/movid-no-neon.ll b/llvm/test/CodeGen/AArch64/movid-no-neon.ll
new file mode 100644
index 000000000000..581b0fb8d385
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/movid-no-neon.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mattr=+fullfp16,+neon < %s | FileCheck %s --check-prefix=NEON-ENABLED
+; RUN: llc -mtriple=aarch64 -mattr=+fullfp16,-neon < %s | FileCheck %s --check-prefix=NEON-DISABLED
+
+define float @get_float() {
+; NEON-ENABLED-LABEL: get_float:
+; NEON-ENABLED: // %bb.0:
+; NEON-ENABLED-NEXT: movi d0, #0000000000000000
+; NEON-ENABLED-NEXT: ret
+;
+; NEON-DISABLED-LABEL: get_float:
+; NEON-DISABLED: // %bb.0:
+; NEON-DISABLED-NEXT: fmov s0, wzr
+; NEON-DISABLED-NEXT: ret
+ ret float 0.000000e+00
+}
+
+define double @get_double() {
+; NEON-ENABLED-LABEL: get_double:
+; NEON-ENABLED: // %bb.0:
+; NEON-ENABLED-NEXT: movi d0, #0000000000000000
+; NEON-ENABLED-NEXT: ret
+;
+; NEON-DISABLED-LABEL: get_double:
+; NEON-DISABLED: // %bb.0:
+; NEON-DISABLED-NEXT: fmov d0, xzr
+; NEON-DISABLED-NEXT: ret
+ ret double 0.000000e+00
+}
+
+define half @get_half() {
+; NEON-ENABLED-LABEL: get_half:
+; NEON-ENABLED: // %bb.0:
+; NEON-ENABLED-NEXT: movi d0, #0000000000000000
+; NEON-ENABLED-NEXT: ret
+;
+; NEON-DISABLED-LABEL: get_half:
+; NEON-DISABLED: // %bb.0:
+; NEON-DISABLED-NEXT: fmov h0, wzr
+; NEON-DISABLED-NEXT: ret
+ ret half 0.000000e+00
+}
More information about the llvm-commits
mailing list