diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index cd7f0e719ad0c..d484fccb92d2f 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -12564,6 +12564,17 @@ bool AArch64TargetLowering::isOffsetFoldingLegal( bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT, bool OptForSize) const { + // If the constant to be materialized is scalar, it maybe efficient to use + // sequence of 'mov + fmov' rather than 'adrp + ldr' on specified CPU's. + // However, when materializing vector of constants, there are two things to + // note: + // 1. Throughput of fmov instruction is very low. + // 2. ldr instruction can load multiple constants in one go. Also, it's + // throughput is higher as compared to fmov. + if (!VT.isVector() && (Subtarget->getCPU() == "neoverse-v2" || + Subtarget->getCPU() == "olympus")) + return true; + bool IsLegal = false; // We can materialize #0.0 as fmov $Rd, XZR for 64-bit, 32-bit cases, and // 16-bit case when target has full fp16 support. diff --git a/llvm/test/CodeGen/AArch64/misched-fusion-addadrp.ll b/llvm/test/CodeGen/AArch64/misched-fusion-addadrp.ll index 70b6b91d3cf66..a30665cbbbc2a 100644 --- a/llvm/test/CodeGen/AArch64/misched-fusion-addadrp.ll +++ b/llvm/test/CodeGen/AArch64/misched-fusion-addadrp.ll @@ -12,7 +12,8 @@ ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n1 | FileCheck %s ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-v1 | FileCheck %s ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n2 | FileCheck %s -; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-v2 | FileCheck %s +; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-v2 | FileCheck %s --check-prefix NO-CONST-POOL +; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=olympus | FileCheck %s --check-prefix NO-CONST-POOL ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=apple-a16 -mattr=-fuse-literals | FileCheck %s ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=apple-a17 -mattr=-fuse-literals | FileCheck %s ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=ampere1 -mattr=-fuse-literals | FileCheck %s @@ -38,6 +39,12 @@ define double @litf() { ; CHECK-LABEL: litf: ; CHECK: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]] ; CHECK-NEXT: ldr {{d[0-9]+}}, {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}} +; +; NO-CONST-POOL: mov [[R:x[0-9]+]], #11544 +; NO-CONST-POOL: movk [[R]], #21572, lsl #16 +; NO-CONST-POOL: movk [[R]], #8699, lsl #32 +; NO-CONST-POOL: movk [[R]], #16393, lsl #48 +; NO-CONST-POOL: fmov {{d[0-9]+}}, [[R]] entry: ret double 0x400921FB54442D18 }