Alex Bradbury c2e84072bd
[RISCV] Set riscv-fpimm-cost threshold to 3 by default (#159352)
`-riscv-fp-imm-cost` controls the threshold at which the constant pool
is used for float constants rather than generating directly (typically
into a GPR followed by an `fmv`). The value used for this knob indicates
the number of instructions that can be used to produce the value
(otherwise we fall back to the constant pool). Upping to to 3 covers a
huge number of additional constants (see
<https://github.com/llvm/llvm-project/issues/153402>), e.g. most whole
numbers which can be generated through lui+shift+fmv. As in general we
struggle with efficient code generation for constant pool accesses,
reducing the number of constant pool accesses is beneficial. We are
typically replacing a two-instruction sequence (which includes a load)
with a three instruction sequence (two simple arithmetic operations plus
a fmv), which.

The CHECK prefixes for various tests had to be updated to avoid
conflicts leading to check lines being dropped altogether (see
<https://github.com/llvm/llvm-project/pull/159321> for a change to
update_llc_test_checks to aid diagnosing this).
2025-09-24 10:50:01 +01:00

33 lines
1.2 KiB
LLVM

; RUN: sed 's/SMALL_DATA_LIMIT/0/g' %s | \
; RUN: llc -mtriple=riscv32 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-0 %s
; RUN: sed 's/SMALL_DATA_LIMIT/0/g' %s | \
; RUN: llc -mtriple=riscv64 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-0 %s
; RUN: sed 's/SMALL_DATA_LIMIT/8/g' %s | \
; RUN: llc -mtriple=riscv32 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-8 %s
; RUN: sed 's/SMALL_DATA_LIMIT/8/g' %s | \
; RUN: llc -mtriple=riscv64 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-8 %s
; RUN: sed 's/SMALL_DATA_LIMIT/16/g' %s | \
; RUN: llc -mtriple=riscv32 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-16 %s
; RUN: sed 's/SMALL_DATA_LIMIT/16/g' %s | \
; RUN: llc -mtriple=riscv64 -mattr=+d | \
; RUN: FileCheck -check-prefix=CHECK-SDL-16 %s
define dso_local double @foo() {
entry:
ret double 0x400A08AC91C3E242
}
!llvm.module.flags = !{!0}
!0 = !{i32 8, !"SmallDataLimit", i32 SMALL_DATA_LIMIT}
; CHECK-SDL-0-NOT: .section .srodata.cst4
; CHECK-SDL-0-NOT: .section .srodata.cst8
; CHECK-SDL-8: .section .srodata.cst8
; CHECK-SDL-16: .section .srodata.cst8