https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106517
Bug ID: 106517 Summary: RISC-V: Inefficient Generated Code for Floating Point to Integer Rounds Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: palmer at gcc dot gnu.org Target Milestone: --- RISC-V has a handful of floating-point conversion instructions that we don't appear to be taking advantage of. For example long f(double in) { return __builtin_floor(in); } generates a call to the floor() library routine, while I believe we can implement in via just a "fcvt.l.d a0, fa0, rdn" (RISC-V clang and arm64 GCC). There are a bunch of similar patterns, the aarch64 test suite seems to have pretty good coverage of them. We should port those tests over to RISC-V, figure out which conversions we can implement directly, and then fix whatever's broken. I started poking around a bit and found that even some of the conversions where we have MD file patterns aren't behaving as expected, so there might be some deeper issue going on. This has come up in a handful of forums lately and while we're still hoping to find some time to look into it, I figured it'd be best to open at least a basic bug so at least we can have one place to track the issues.