[llvm] ISel/AArch64: custom lower vector ISD::[L]LRINT (PR #89035)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 12:03:13 PDT 2024
================
@@ -4362,6 +4379,25 @@ SDValue AArch64TargetLowering::LowerFP_TO_INT_SAT(SDValue Op,
return DAG.getNode(ISD::TRUNCATE, DL, DstVT, Sat);
}
+SDValue AArch64TargetLowering::LowerVectorXRINT(SDValue Op,
+ SelectionDAG &DAG) const {
+ EVT VT = Op.getValueType();
+ SDValue Src = Op.getOperand(0);
+ SDLoc DL(Op);
+
+ assert(VT.isVector() && "Expected vector type");
+
+ EVT CastVT =
+ VT.changeVectorElementType(Src.getValueType().getVectorElementType());
+
+ // Round the floating-point value into a floating-point register with the
+ // current rounding mode.
+ SDValue FOp = DAG.getNode(ISD::FRINT, DL, CastVT, Src);
+
+ // Truncate the rounded floating point to an integer, rounding to zero.
+ return DAG.getNode(ISD::FP_TO_SINT, DL, VT, FOp);
----------------
efriedma-quic wrote:
ISD::LRINT can't raise an exception (at least, nothing can tell if it does); only ISD::STRICT_LRINT can, and you're not handling that here.
LangRef says the return value of an out-of-range LRINT is "equivalent to freeze poison". But FP_TO_SINT just returns poison... so you can't use it.
I guess you could, alternatively, freeze the result of FP_TO_SINT, but that isn't really an improvement.
https://github.com/llvm/llvm-project/pull/89035
More information about the llvm-commits
mailing list