Skip to content

Commit 94b9029

Browse files
committed
[FPEnv] Support constrained FREM intrinsic
Differential Revision: https://reviews.llvm.org/D50975 llvm-svn: 340201
1 parent 5ca4128 commit 94b9029

File tree

6 files changed

+296
-14
lines changed

6 files changed

+296
-14
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ class TargetLoweringBase {
798798
case ISD::STRICT_FSUB: EqOpc = ISD::FSUB; break;
799799
case ISD::STRICT_FMUL: EqOpc = ISD::FMUL; break;
800800
case ISD::STRICT_FDIV: EqOpc = ISD::FDIV; break;
801+
case ISD::STRICT_FREM: EqOpc = ISD::FREM; break;
801802
case ISD::STRICT_FSQRT: EqOpc = ISD::FSQRT; break;
802803
case ISD::STRICT_FPOW: EqOpc = ISD::FPOW; break;
803804
case ISD::STRICT_FPOWI: EqOpc = ISD::FPOWI; break;

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
10941094
case ISD::STRICT_FSUB:
10951095
case ISD::STRICT_FMUL:
10961096
case ISD::STRICT_FDIV:
1097+
case ISD::STRICT_FREM:
10971098
case ISD::STRICT_FSQRT:
10981099
case ISD::STRICT_FMA:
10991100
case ISD::STRICT_FPOW:
@@ -4188,6 +4189,7 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
41884189
RTLIB::DIV_PPCF128));
41894190
break;
41904191
case ISD::FREM:
4192+
case ISD::STRICT_FREM:
41914193
Results.push_back(ExpandFPLibCall(Node, RTLIB::REM_F32, RTLIB::REM_F64,
41924194
RTLIB::REM_F80, RTLIB::REM_F128,
41934195
RTLIB::REM_PPCF128));

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
298298
case ISD::STRICT_FSUB:
299299
case ISD::STRICT_FMUL:
300300
case ISD::STRICT_FDIV:
301+
case ISD::STRICT_FREM:
301302
case ISD::STRICT_FSQRT:
302303
case ISD::STRICT_FMA:
303304
case ISD::STRICT_FPOW:
@@ -739,6 +740,7 @@ SDValue VectorLegalizer::Expand(SDValue Op) {
739740
case ISD::STRICT_FSUB:
740741
case ISD::STRICT_FMUL:
741742
case ISD::STRICT_FDIV:
743+
case ISD::STRICT_FREM:
742744
case ISD::STRICT_FSQRT:
743745
case ISD::STRICT_FMA:
744746
case ISD::STRICT_FPOW:

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
143143
case ISD::STRICT_FSUB:
144144
case ISD::STRICT_FMUL:
145145
case ISD::STRICT_FDIV:
146+
case ISD::STRICT_FREM:
146147
case ISD::STRICT_FSQRT:
147148
case ISD::STRICT_FMA:
148149
case ISD::STRICT_FPOW:
@@ -808,6 +809,7 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
808809
case ISD::STRICT_FSUB:
809810
case ISD::STRICT_FMUL:
810811
case ISD::STRICT_FDIV:
812+
case ISD::STRICT_FREM:
811813
case ISD::STRICT_FSQRT:
812814
case ISD::STRICT_FMA:
813815
case ISD::STRICT_FPOW:
@@ -2373,6 +2375,7 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
23732375
case ISD::STRICT_FSUB:
23742376
case ISD::STRICT_FMUL:
23752377
case ISD::STRICT_FDIV:
2378+
case ISD::STRICT_FREM:
23762379
case ISD::STRICT_FSQRT:
23772380
case ISD::STRICT_FMA:
23782381
case ISD::STRICT_FPOW:

llvm/test/CodeGen/X86/fp-intrinsics.ll

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,24 @@ entry:
274274
ret double %result
275275
}
276276

277+
; CHECK-LABEL: f19
278+
; COMMON: fmod
279+
define double @f19() {
280+
entry:
281+
%rem = call double @llvm.experimental.constrained.frem.f64(
282+
double 1.000000e+00,
283+
double 1.000000e+01,
284+
metadata !"round.dynamic",
285+
metadata !"fpexcept.strict")
286+
ret double %rem
287+
}
288+
277289
@llvm.fp.env = thread_local global i8 zeroinitializer, section "llvm.metadata"
278-
declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata)
279-
declare double @llvm.experimental.constrained.fmul.f64(double, double, metadata, metadata)
280290
declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
281291
declare double @llvm.experimental.constrained.fsub.f64(double, double, metadata, metadata)
292+
declare double @llvm.experimental.constrained.fmul.f64(double, double, metadata, metadata)
293+
declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata)
294+
declare double @llvm.experimental.constrained.frem.f64(double, double, metadata, metadata)
282295
declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
283296
declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
284297
declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata)

0 commit comments

Comments
 (0)