diff options
author | Benjamin Maxwell <benjamin.maxwell@arm.com> | 2025-02-07 09:25:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-07 09:25:13 +0000 |
commit | 4bf97aa818965d86055c762a42f6d518e8e3a21e (patch) | |
tree | 8e79e3eb4db6bb3a3954e3a2a7306d882454fc6b /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | ac158aa13b5a81552e45e63f534420c38e514484 (diff) | |
download | llvm-4bf97aa818965d86055c762a42f6d518e8e3a21e.zip llvm-4bf97aa818965d86055c762a42f6d518e8e3a21e.tar.gz llvm-4bf97aa818965d86055c762a42f6d518e8e3a21e.tar.bz2 |
[IR] Add `llvm.modf` intrinsic (#121948)
This adds the `llvm.modf` intrinsic, legalization, and lowering (mostly
reusing the lowering for sincos and frexp).
The `llvm.modf` intrinsic takes a floating-point value and returns both
the integral and fractional parts (as a struct).
```
declare { float, float } @llvm.modf.f32(float %Val)
declare { double, double } @llvm.modf.f64(double %Val)
declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80 %Val)
declare { fp128, fp128 } @llvm.modf.f128(fp128 %Val)
declare { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %Val)
declare { <4 x float>, <4 x float> } @llvm.modf.v4f32(<4 x float> %Val)
```
This corresponds to the libm `modf` function but returns multiple values
in a struct (rather than take output pointers), which makes it easier to
vectorize.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 9c56912..1f39ec20 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -407,6 +407,11 @@ RTLIB::Libcall RTLIB::getFSINCOS(EVT RetVT) { SINCOS_PPCF128); } +RTLIB::Libcall RTLIB::getMODF(EVT RetVT) { + return getFPLibCall(RetVT, MODF_F32, MODF_F64, MODF_F80, MODF_F128, + MODF_PPCF128); +} + RTLIB::Libcall RTLIB::getOutlineAtomicHelper(const Libcall (&LC)[5][4], AtomicOrdering Order, uint64_t MemSize) { @@ -775,9 +780,9 @@ void TargetLoweringBase::initActions() { setOperationAction({ISD::BITREVERSE, ISD::PARITY}, VT, Expand); // These library functions default to expand. - setOperationAction( - {ISD::FROUND, ISD::FPOWI, ISD::FLDEXP, ISD::FFREXP, ISD::FSINCOS}, VT, - Expand); + setOperationAction({ISD::FROUND, ISD::FPOWI, ISD::FLDEXP, ISD::FFREXP, + ISD::FSINCOS, ISD::FMODF}, + VT, Expand); // These operations default to expand for vector types. if (VT.isVector()) |