public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/103541] New: unnecessary spills around const functions calls Date: Fri, 03 Dec 2021 15:16:13 +0000 [thread overview] Message-ID: <bug-103541-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103541 Bug ID: 103541 Summary: unnecessary spills around const functions calls Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- While looking into reasons why modref causes some code size increases I noticed that we produce unnecessary spill on x86-64 here: float a; __attribute__((const)) float foo (float); float test() { return a + foo(a) + a; } we load "a" into register and then spill it to stack because all SSE registers are clobbered by the call. This seems to happen somewhere between gcc 4.1 and 4.6. It is caused by: /* We can combine a reg def from one insn into a reg use in another over a call if the memory is readonly or the call const/pure. However, we can't set reg_equiv notes up for reload over any call. The problem is the equivalent form may reference a pseudo which gets assigned a call clobbered hard reg. When we later replace REG with its equivalent form, the value in the call-clobbered reg has been changed and all hell breaks loose. */ ret = valid_combine; if (!MEM_READONLY_P (memref) && !RTL_CONST_OR_PURE_CALL_P (insn)) return valid_none; in ira.c:validate_equiv_mem If I read the comment correctly it is afraid of the address of memory reading being altered by the call (using call clobbered registers). But here it is a constant, so perhaps we can just rule this out when MEM rtx does not mention registers or does not mention any callee clobbered registers?
next reply other threads:[~2021-12-03 15:16 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-03 15:16 hubicka at gcc dot gnu.org [this message] 2021-12-03 20:35 ` [Bug rtl-optimization/103541] " pinskia at gcc dot gnu.org 2021-12-03 20:35 ` pinskia at gcc dot gnu.org 2021-12-03 20:37 ` pinskia at gcc dot gnu.org 2023-02-03 23:15 ` vmakarov at gcc dot gnu.org 2023-02-07 14:05 ` cvs-commit at gcc dot gnu.org 2023-02-08 22:30 ` hjl.tools at gmail dot com 2023-02-09 21:48 ` cvs-commit 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-103541-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).