[llvm] ISel: introduce vector ISD::LRINT, ISD::LLRINT; custom RISCV lowering (PR #66924)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 04:59:37 PDT 2023


================
@@ -17206,6 +17210,21 @@ SDValue DAGCombiner::visitFP_TO_UINT(SDNode *N) {
   return FoldIntToFPToInt(N, DAG);
 }
 
+SDValue DAGCombiner::visitXRINT(SDNode *N) {
+  SDValue N0 = N->getOperand(0);
+  EVT VT = N->getValueType(0);
+
+  // fold (lrint|llrint undef) -> undef
+  if (N0.isUndef())
+    return DAG.getUNDEF(VT);
+
+  // fold (lrint|llrint c1fp) -> c1
+  if (DAG.isConstantFPBuildVectorOrConstantFP(N0))
+    return DAG.getNode(N->getOpcode(), SDLoc(N), VT, N0);
----------------
artagnon wrote:

It is impossible to recover the FP after converting FP to int with rounding, so I don't think we can do any constant folding similar to `FoldIntToFPToInt`. I've investigated `canConstantFoldCallTo`, and it doesn't seem to be of particular interest in the context of [l]lrint either.

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


More information about the llvm-commits mailing list