https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115264
Bug ID: 115264 Summary: RISC-V: yet another instance of poor codegen related to stack (glibc tmpnam.c) Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vineetg at gcc dot gnu.org CC: jeffreyalaw at gmail dot com, kito.cheng at gmail dot com Target Milestone: --- When working on sum of two s12 optim for function prologue/epilogue noticed that glibc tempnam.c generates really poor code (as compared to llvm trunk) --->8----- typedef long unsigned int size_t; extern int __gen_tempname (char *__tmpl, int __suffixlen, int __flags, int __kind); extern char *__strdup (const char *__string); extern int __path_search (char *__tmpl, size_t __tmpl_len, const char *__dir, const char *__pfx, int __try_tempdir); char * tempnam (const char *dir, const char *pfx) { char buf[4096]; if (__path_search (buf, 4096, dir, pfx, 1)) return ((void *)0) ; if (__gen_tempname (buf, 0, 0, 2)) return ((void *)0) ; return __strdup (buf); } --->8----- - There's two copies of epilogue (for no seemingly obvious benefit) - s0 is needlessly being spilled (likely one of RA passes generate the refs but subsequent passes failing to eliminate) - sum of two s12 making it worse.