[llvm] [NVPTX] Custom lower integer<->bf16 conversions for sm_80 (PR #74827)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 10:56:27 PST 2023
================
@@ -2580,6 +2586,37 @@ SDValue NVPTXTargetLowering::LowerFROUND64(SDValue Op,
return DAG.getNode(ISD::SELECT, SL, VT, IsLarge, A, RoundedA);
}
+SDValue NVPTXTargetLowering::LowerINT_TO_FP(SDValue Op,
+ SelectionDAG &DAG) const {
+ // sm_90 has instructions for bf16 conversions, sm_80 only has f32 -> bf16.
+ if (Op.getValueType() == MVT::bf16 &&
+ (STI.getSmVersion() < 90 || STI.getPTXVersion() < 78)) {
+ SDLoc Loc(Op);
+ return DAG.getNode(
+ ISD::FP_ROUND, Loc, MVT::bf16,
----------------
Artem-B wrote:
LLVM also has `BF16_TO_FP` op, which may be a better fit than generic FP_ROUND. I'm not sure if it would buy us anything useful here. Looks like LLVM would try to lower it to integer extend to i32 and `shl 16`. It may give LLVM a bit more freedom, though I suspect PTX own conversion bf16->fp32 would expand into about the same SASS in the end.
https://github.com/llvm/llvm-project/pull/74827
More information about the llvm-commits
mailing list