[llvm] [ARM] Mark function calls as possibly changing FPSCR (PR #160699)
Erik Enikeev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 08:04:52 PDT 2025
https://github.com/Varnike updated https://github.com/llvm/llvm-project/pull/160699
>From 4c4b8215427b0880830f5574cb1a258d480411d2 Mon Sep 17 00:00:00 2001
From: Erik Enikeev <evonatarius at gmail.com>
Date: Wed, 27 Aug 2025 18:10:26 +0300
Subject: [PATCH 1/2] [ARM] Mark function calls as possibly changing FPSCR
This patch does the same changes as D143001 for AArch64
---
llvm/lib/Target/ARM/ARMISelLowering.cpp | 5 +++++
llvm/lib/Target/ARM/ARMISelLowering.h | 2 ++
llvm/test/CodeGen/ARM/strict-fp-func.ll | 13 +++++++++++++
3 files changed, 20 insertions(+)
create mode 100644 llvm/test/CodeGen/ARM/strict-fp-func.ll
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 9052cbfa89deb..4f9616f09b4ea 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -22003,6 +22003,11 @@ bool ARMTargetLowering::isComplexDeinterleavingOperationSupported(
ScalarTy->isIntegerTy(32));
}
+ArrayRef<MCPhysReg> ARMTargetLowering::getRoundingControlRegisters() const {
+ static const MCPhysReg RCRegs[] = {ARM::FPSCR};
+ return RCRegs;
+}
+
Value *ARMTargetLowering::createComplexDeinterleavingIR(
IRBuilderBase &B, ComplexDeinterleavingOperation OperationType,
ComplexDeinterleavingRotation Rotation, Value *InputA, Value *InputB,
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h
index 8e417ac3e1a7b..7fd4c0b1fb2f5 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.h
+++ b/llvm/lib/Target/ARM/ARMISelLowering.h
@@ -995,6 +995,8 @@ class VectorType;
bool isUnsupportedFloatingType(EVT VT) const;
+ ArrayRef<MCPhysReg> getRoundingControlRegisters() const override;
+
SDValue getCMOV(const SDLoc &dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
SDValue ARMcc, SDValue Flags, SelectionDAG &DAG) const;
SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
diff --git a/llvm/test/CodeGen/ARM/strict-fp-func.ll b/llvm/test/CodeGen/ARM/strict-fp-func.ll
new file mode 100644
index 0000000000000..198d4fdea6831
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/strict-fp-func.ll
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple aarch64-none-linux-gnu -stop-after=finalize-isel %s -o - | FileCheck %s
+
+define float @func_02(float %x, float %y) strictfp nounwind {
+ %call = call float @func_01(float %x) strictfp
+ %res = call float @llvm.experimental.constrained.fadd.f32(float %call, float %y, metadata !"round.dynamic", metadata !"fpexcept.ignore") strictfp
+ ret float %res
+}
+; CHECK-LABEL: name: func_02
+; CHECK: BL @func_01, {{.*}}, implicit-def $fpcr
+
+
+declare float @func_01(float)
+declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
>From 56dbb5550569c35685a025813b65cf3a7fb33bc3 Mon Sep 17 00:00:00 2001
From: Erik Enikeev <evonatarius at gmail.com>
Date: Mon, 29 Sep 2025 15:42:33 +0300
Subject: [PATCH 2/2] fixup: use FPSCR_RM instead of FPSCR and correct test
target
---
llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +-
llvm/test/CodeGen/ARM/strict-fp-func.ll | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 4f9616f09b4ea..fe8d8ff3325a0 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -22004,7 +22004,7 @@ bool ARMTargetLowering::isComplexDeinterleavingOperationSupported(
}
ArrayRef<MCPhysReg> ARMTargetLowering::getRoundingControlRegisters() const {
- static const MCPhysReg RCRegs[] = {ARM::FPSCR};
+ static const MCPhysReg RCRegs[] = {ARM::FPSCR_RM};
return RCRegs;
}
diff --git a/llvm/test/CodeGen/ARM/strict-fp-func.ll b/llvm/test/CodeGen/ARM/strict-fp-func.ll
index 198d4fdea6831..39bb2b46bdac5 100644
--- a/llvm/test/CodeGen/ARM/strict-fp-func.ll
+++ b/llvm/test/CodeGen/ARM/strict-fp-func.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple aarch64-none-linux-gnu -stop-after=finalize-isel %s -o - | FileCheck %s
+; RUN: llc -mtriple arm-none-eabi -stop-after=finalize-isel %s -o - | FileCheck %s
define float @func_02(float %x, float %y) strictfp nounwind {
%call = call float @func_01(float %x) strictfp
@@ -6,7 +6,7 @@ define float @func_02(float %x, float %y) strictfp nounwind {
ret float %res
}
; CHECK-LABEL: name: func_02
-; CHECK: BL @func_01, {{.*}}, implicit-def $fpcr
+; CHECK: BL @func_01, {{.*}}, implicit-def $fpscr_rm
declare float @func_01(float)
More information about the llvm-commits
mailing list