#include #if __riscv_flen >= 32 float roundf(float x) { if (isnan(x + x)) return x; if (fabsf(x) >= 0x1p25) return x; float tmp; long n; __asm__ ("fcvt.w.s %0, %1, rmm" : "=r"(n) : "f"(x)); __asm__ ("fcvt.s.w %0, %1" : "=f"(tmp) : "r"(n)); __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(tmp), "f"(x)); return x; } #else #include "../roundf.c" #endif