public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug target/109972] New: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension @ 2023-05-25 22:43 craig.topper at gmail dot com 2023-06-01 21:30 ` [Bug target/109972] " palmer at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: craig.topper at gmail dot com @ 2023-05-25 22:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109972 Bug ID: 109972 Summary: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: craig.topper at gmail dot com Target Milestone: --- There's an opportunity to improve code size for 32-bit division and remainder on RV64 without the M extension. Currently gcc calls the umoddi3/udivdi3/divdi3 functions by zero/sign extending the operands. In the case of the unsigned functions this requires two shifts to zero the upper bits. For signed, it's two sext.w if the operands are not already sign extended. All 3 functions are followed by a sext.w if the result needs be sign extended. libgcc contains umodsi3/udivsi3/divsi3 functions that handle the zero extending of inputs and sign extending the result. Internally they call the di3 functions to do the computation. These functions could be used to reduce code size at the caller. There is no signed modsi3 function in libgcc. Probably because umoddi3(sext(X), sext(Y)) is guaranteed to produce a result that is sign extended. gcc seems to not know this and still emits a sext.w after the call to umoddi3. godbolt https://godbolt.org/z/ax3Khc6cM unsigned divu(unsigned x, unsigned y) { return x / y; } unsigned remu(unsigned x, unsigned y) { return x % y; } int div(int x, int y) { return x / y; } int rem(int x, int y) { return x % y; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/109972] RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension 2023-05-25 22:43 [Bug target/109972] New: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension craig.topper at gmail dot com @ 2023-06-01 21:30 ` palmer at gcc dot gnu.org 2023-06-01 21:40 ` pinskia at gcc dot gnu.org 2023-06-02 7:33 ` kito at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: palmer at gcc dot gnu.org @ 2023-06-01 21:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109972 palmer at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |palmer at gcc dot gnu.org Status|UNCONFIRMED |NEW Last reconfirmed| |2023-06-01 Severity|normal |enhancement --- Comment #1 from palmer at gcc dot gnu.org --- Thanks. Craig and I had talked about this offline, it looks like a real improvement to me. We're not super worried about rv32 or code size, maybe Kito is? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/109972] RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension 2023-05-25 22:43 [Bug target/109972] New: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension craig.topper at gmail dot com 2023-06-01 21:30 ` [Bug target/109972] " palmer at gcc dot gnu.org @ 2023-06-01 21:40 ` pinskia at gcc dot gnu.org 2023-06-02 7:33 ` kito at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-01 21:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109972 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to palmer from comment #1) > Thanks. Craig and I had talked about this offline, it looks like a real > improvement to me. We're not super worried about rv32 or code size, maybe > Kito is? I am care about RV32 code quality though the core I am working with has the M extension so this case is not as important to me. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/109972] RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension 2023-05-25 22:43 [Bug target/109972] New: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension craig.topper at gmail dot com 2023-06-01 21:30 ` [Bug target/109972] " palmer at gcc dot gnu.org 2023-06-01 21:40 ` pinskia at gcc dot gnu.org @ 2023-06-02 7:33 ` kito at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: kito at gcc dot gnu.org @ 2023-06-02 7:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109972 --- Comment #3 from Kito Cheng <kito at gcc dot gnu.org> --- We care but it's lower priority compare to other configuration, so create bug to tracking here should be best solution for now :P ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-02 7:33 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-05-25 22:43 [Bug target/109972] New: RISC-V: Could use umodsi3/udivsi3/divsi3 libcalls for 32-bit division/remainder on RV64 without M extension craig.topper at gmail dot com 2023-06-01 21:30 ` [Bug target/109972] " palmer at gcc dot gnu.org 2023-06-01 21:40 ` pinskia at gcc dot gnu.org 2023-06-02 7:33 ` kito at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).