Skip to content

Commit b540162

Browse files
DAG: Add RTLIB::getPOW helper (#147274)
Co-authored-by: Paul Walker <paul.walker@arm.com>
1 parent db389bd commit b540162

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

llvm/include/llvm/CodeGen/RuntimeLibcallUtil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT);
5656
/// UNKNOWN_LIBCALL if there is none.
5757
LLVM_ABI Libcall getPOWI(EVT RetVT);
5858

59+
/// getPOW - Return the POW_* value for the given types, or
60+
/// UNKNOWN_LIBCALL if there is none.
61+
LLVM_ABI Libcall getPOW(EVT RetVT);
62+
5963
/// getLDEXP - Return the LDEXP_* value for the given types, or
6064
/// UNKNOWN_LIBCALL if there is none.
6165
LLVM_ABI Libcall getLDEXP(EVT RetVT);

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,7 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FP_ROUND(SDNode *N) {
704704
}
705705

706706
SDValue DAGTypeLegalizer::SoftenFloatRes_FPOW(SDNode *N) {
707-
return SoftenFloatRes_Binary(N, GetFPLibCall(N->getValueType(0),
708-
RTLIB::POW_F32,
709-
RTLIB::POW_F64,
710-
RTLIB::POW_F80,
711-
RTLIB::POW_F128,
712-
RTLIB::POW_PPCF128));
707+
return SoftenFloatRes_Binary(N, RTLIB::getPOW(N->getValueType(0)));
713708
}
714709

715710
SDValue DAGTypeLegalizer::SoftenFloatRes_ExpOp(SDNode *N) {
@@ -723,6 +718,9 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_ExpOp(SDNode *N) {
723718
: RTLIB::getLDEXP(N->getValueType(0));
724719
assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected fpowi.");
725720
if (!TLI.getLibcallName(LC)) {
721+
RTLIB::Libcall NewLC = RTLIB::getPOW(N->getValueType(0));
722+
assert(NewLC != RTLIB::UNKNOWN_LIBCALL && "Unexpected fpow type");
723+
726724
// Some targets don't have a powi libcall; use pow instead.
727725
// FIXME: Implement this if some target needs it.
728726
DAG.getContext()->emitError("do not know how to soften fpowi to fpow");

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ RTLIB::Libcall RTLIB::getPOWI(EVT RetVT) {
396396
POWI_PPCF128);
397397
}
398398

399+
RTLIB::Libcall RTLIB::getPOW(EVT RetVT) {
400+
return getFPLibCall(RetVT, POW_F32, POW_F64, POW_F80, POW_F128, POW_PPCF128);
401+
}
402+
399403
RTLIB::Libcall RTLIB::getLDEXP(EVT RetVT) {
400404
return getFPLibCall(RetVT, LDEXP_F32, LDEXP_F64, LDEXP_F80, LDEXP_F128,
401405
LDEXP_PPCF128);

0 commit comments

Comments
 (0)