For ceil, floor, and trunc we have existing custom lowering for vectors. This change extends that custom lowering for the scalar cases. One slight subtlety with the scalar case is that we must use the full XLEN for the integer type, and that for doubles on riscv32 we can't use this as we can't round trip the full range through integer.
I would appreciate careful review here. I am by no means a floating point expert. My reasoning on the correctness of this basically comes down to matching what the vector code already does and the knowledge that rounding modes are shared between scalar and vector so if the existing code gets that right, then presumably so must the scalar version.