[PATCH] D29942: Add custom lowering for llvm.log.f32 intrinsic
Vedran Miletić via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 07:42:33 PST 2017
rivanvx created this revision.
Herald added subscribers: tpr, nhaehnle, arsenm.
Presently AMDGPU backend errors with "unsupported call to function" upon encountering a call to llvm.log.f32 intrinsic. This patch adds custom lowering to avoid that error.
Repository:
rL LLVM
https://reviews.llvm.org/D29942
Files:
lib/Target/AMDGPU/SIISelLowering.cpp
lib/Target/AMDGPU/SIISelLowering.h
Index: lib/Target/AMDGPU/SIISelLowering.h
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.h
+++ lib/Target/AMDGPU/SIISelLowering.h
@@ -42,6 +42,7 @@
SDValue LowerFDIV32(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerFDIV64(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const;
+ SDValue LowerFLOG(SDValue Op, SelectionDAG &Dag) const;
SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool Signed) const;
SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -294,6 +294,9 @@
setOperationAction(ISD::FDIV, MVT::f32, Custom);
setOperationAction(ISD::FDIV, MVT::f64, Custom);
+ setOperationAction(ISD::FLOG, MVT::f32, Custom);
+ setOperationAction(ISD::FLOG, MVT::f64, Custom);
+
if (Subtarget->has16BitInsts()) {
setOperationAction(ISD::Constant, MVT::i16, Legal);
@@ -1978,6 +1981,7 @@
return LowerTrig(Op, DAG);
case ISD::SELECT: return LowerSELECT(Op, DAG);
case ISD::FDIV: return LowerFDIV(Op, DAG);
+ case ISD::FLOG: return LowerFLOG(Op, DAG);
case ISD::ATOMIC_CMP_SWAP: return LowerATOMIC_CMP_SWAP(Op, DAG);
case ISD::STORE: return LowerSTORE(Op, DAG);
case ISD::GlobalAddress: {
@@ -3464,6 +3468,18 @@
llvm_unreachable("Unexpected type for fdiv");
}
+SDValue SITargetLowering::LowerFLOG(SDValue Op, SelectionDAG &DAG) const {
+ EVT VT = Op.getValueType();
+
+ SDLoc SL(Op);
+ SDValue Operand = Op.getOperand(0);
+
+ SDValue Log2Operand = DAG.getNode(ISD::FLOG2, SL, VT, Operand);
+ const SDValue Log2e = DAG.getConstantFP(M_LOG2E, SL, VT);
+
+ return DAG.getNode(ISD::FDIV, SL, VT, Log2Operand, Log2e);
+}
+
SDValue SITargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
SDLoc DL(Op);
StoreSDNode *Store = cast<StoreSDNode>(Op);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29942.88374.patch
Type: text/x-patch
Size: 2088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170214/64b739c3/attachment.bin>
More information about the llvm-commits
mailing list