public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcc at gms dot tf" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94173] New: [RISCV] Superfluous stackpointer manipulation Date: Sat, 14 Mar 2020 09:04:14 +0000 [thread overview] Message-ID: <bug-94173-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94173 Bug ID: 94173 Summary: [RISCV] Superfluous stackpointer manipulation Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: gcc at gms dot tf Target Milestone: --- Created attachment 48033 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48033&action=edit demonstrate how bar function yields superfluous stackpointer instructions GCC emits stackpointer decrement/increment instructions in some functions where they are superfluous. Example: struct Pair { char *s; char *t; }; typedef struct Pair Pair; Pair bar(char *s, char *t) { return (Pair){s, t}; } Expected assembly: 0000000000000002 <bar>: 2: 8082 ret Actual assembly: 0000000000000002 <bar>: 2: 1141 addi sp,sp,-16 4: 0141 addi sp,sp,16 6: 8082 ret Notes: In an example where the function just returns one value the assembly code actually just contain the expected assenbly code: char *foo(char *s, char *t) { return s; } Note that per the RISC-V calling-conventions up to 2 integer like values are returned via the a0/a1 registers, i.e. the same registers where also the first 2 function arguments are placed. FWIW, Clang 9.0.1 generates for both examples the expected code without superfluous stackpointer adjustments. Example code is attched. I tested with: riscv64-linux-gnu-gcc -O3 -c -o pair.o pair.c
next reply other threads:[~2020-03-14 9:04 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-14 9:04 gcc at gms dot tf [this message] 2020-03-16 22:21 ` [Bug target/94173] " wilson at gcc dot gnu.org 2020-03-16 22:21 ` wilson at gcc dot gnu.org 2020-03-16 22:27 ` andrew at sifive dot com 2020-03-16 22:34 ` wilson at gcc dot gnu.org 2024-08-04 22:38 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94173-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).