[llvm] [TargetLowering][SelectionDAG] Exploit nneg Flag in UINT_TO_FP (PR #108931)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 02:03:28 PDT 2024


================
@@ -8361,18 +8361,26 @@ bool TargetLowering::expandFP_TO_UINT(SDNode *Node, SDValue &Result,
 }
 
 bool TargetLowering::expandUINT_TO_FP(SDNode *Node, SDValue &Result,
-                                      SDValue &Chain,
-                                      SelectionDAG &DAG) const {
+                                      SDValue &Chain, SelectionDAG &DAG) const {
+  SDValue Src = Node->getOperand(0);
+  EVT SrcVT = Src.getValueType();
+  EVT DstVT = Node->getValueType(0);
+
+  // If the input is known to be non-negative and SINT_TO_FP is legal then use
+  // it.
+  if (Node->getFlags().hasNonNeg() &&
+      isOperationLegalOrCustom(ISD::SINT_TO_FP, DstVT)) {
----------------
arsenm wrote:

SINT_TO_FP is one of the opcodes that checks the legality based on the source type, not the result type. This is bad because you really need to know both types 

https://github.com/llvm/llvm-project/pull/108931


More information about the llvm-commits mailing list