[llvm] [RISCV]: Implemented softening of `FCANONICALIZE` (PR #169234)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 23 14:47:20 PST 2025


================
@@ -311,6 +313,12 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(SDNode *N) {
   return DAG.getNode(ISD::AND, SDLoc(N), NVT, Op, Mask);
 }
 
+SDValue DAGTypeLegalizer::SoftenFloatRes_FCANONICALIZE(SDNode *N) {
+  return SoftenFloatRes_Unary(
+      N, GetFPLibCall(N->getValueType(0), RTLIB::FMIN_F32, RTLIB::FMIN_F64,
----------------
topperc wrote:

I'm not sure the FMIN libcall is guaranteed to be a valid way to canonicalize. I don't think FMIN is required to preserve the sign of zero for example.

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


More information about the llvm-commits mailing list