public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/103541] New: unnecessary spills around const functions calls
@ 2021-12-03 15:16 hubicka at gcc dot gnu.org
  2021-12-03 20:35 ` [Bug rtl-optimization/103541] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-12-03 15:16 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-09 21:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 15:16 [Bug rtl-optimization/103541] New: unnecessary spills around const functions calls hubicka at gcc dot gnu.org
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

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).