[llvm] [X86] Combine FRINT + FP_TO_SINT to LRINT (PR #126477)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 00:59:32 PST 2025
================
@@ -56380,6 +56381,17 @@ static SDValue combineSIntToFP(SDNode *N, SelectionDAG &DAG,
return SDValue();
}
+static SDValue combineFPToSInt(SDNode *N, SelectionDAG &DAG,
+ const X86Subtarget &Subtarget) {
+ EVT VT = N->getValueType(0);
+ SDValue Src = N->getOperand(0);
+ if (Src.getOpcode() == ISD::FRINT && VT.getScalarType() == MVT::i32 &&
+ Src.hasOneUse())
+ return DAG.getNode(ISD::LRINT, SDLoc(N), VT, Src.getOperand(0));
----------------
phoebewang wrote:
> > > Do we need to check soft float and no-sse+no-x87 to avoid creating libcalls with the wrong register? Maybe isTypeLegal for the FP type is enough?
> >
> >
> > I don't think so. It is different with #126217, 1) we don't combine TRUNC this time, so we won't eliminate ZEXT; 2) we based on the fact the out of range result is UB. We don't care the result in this case.
>
> I think creating libcalls with the wrong register class is in general a bad idea even we can't find a functional issue with it.
Add checking for SSE2.
https://github.com/llvm/llvm-project/pull/126477
More information about the llvm-commits
mailing list