[llvm] Porting `LowerFP_TO_INT()` and LowerINT_TO_FP()` to `TargetLowering.cpp` (PR #118831)
Aidan Goldfarb via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 09:12:36 PST 2024
https://github.com/AidanGoldfarb created https://github.com/llvm/llvm-project/pull/118831
Addressing #116695, int->fp and fp->int
>From a1d09724c318aa24c8bd26b90a6dd62fb4125784 Mon Sep 17 00:00:00 2001
From: Aidan <aidan.goldfarb at mail.mcgill.ca>
Date: Thu, 5 Dec 2024 12:10:50 -0500
Subject: [PATCH] draft commit for targetlowering port
---
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index eeba4b7d20f9c1..0f21eae7883dea 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -8413,6 +8413,17 @@ bool TargetLowering::expandUINT_TO_FP(SDNode *Node, SDValue &Result,
EVT SrcVT = Src.getValueType();
EVT DstVT = Node->getValueType(0);
+ if (DstVT == MVT::bf16) {
+ SDLoc Loc(Node);
+ SDValue Operand = Node->getOperand(0);
+
+ Result = DAG.getNode(
+ ISD::FP_ROUND, Loc, MVT::bf16,
+ DAG.getNode(ISD::UINT_TO_FP, Loc, MVT::f32, Operand),
+ DAG.getIntPtrConstant(0, Loc));
+ return true;
+ }
+
// If the input is known to be non-negative and SINT_TO_FP is legal then use
// it.
if (Node->getFlags().hasNonNeg() &&
More information about the llvm-commits
mailing list