public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/96175] New: Failure to optimize memory stores of double literals properly
@ 2020-07-12 17:02 gabravier at gmail dot com
  2020-07-12 17:10 ` [Bug target/96175] " pinskia at gcc dot gnu.org
  2020-07-13  8:15 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2020-07-12 17:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96175

            Bug ID: 96175
           Summary: Failure to optimize memory stores of double literals
                    properly
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

void f(double *x)
{
    *x = 1.0;
}

With -O3, LLVM generates this :

f(double*): # @f(double*)
  movabs rax, 4607182418800017408
  mov qword ptr [rdi], rax
  ret

GCC generates this :

f(double*):
  mov rax, QWORD PTR .LC0[rip]
  mov QWORD PTR [rdi], rax
  ret
.LC0:
  .long 0
  .long 1072693248

This also occurs on every other architecture I tested (arm and powerpc64le,
though only with GCC 9). GCC is weirdly insistent on having a literal stored in
const data instead of just having it in the code, which seems inefficient.

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

* [Bug target/96175] Failure to optimize memory stores of double literals properly
  2020-07-12 17:02 [Bug middle-end/96175] New: Failure to optimize memory stores of double literals properly gabravier at gmail dot com
@ 2020-07-12 17:10 ` pinskia at gcc dot gnu.org
  2020-07-13  8:15 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-07-12 17:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96175

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Each target decides how liberals are handled.  So this is a target issue.  Iirc
aarch64 was fixed in gcc 10 for an example.

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

* [Bug target/96175] Failure to optimize memory stores of double literals properly
  2020-07-12 17:02 [Bug middle-end/96175] New: Failure to optimize memory stores of double literals properly gabravier at gmail dot com
  2020-07-12 17:10 ` [Bug target/96175] " pinskia at gcc dot gnu.org
@ 2020-07-13  8:15 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-13  8:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96175

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-07-13
     Ever confirmed|0                           |1
             Target|                            |x86_64-*-* i?86-*-*
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think one issue is we don't know how many times a constant literal is used
and thus for example for -Os whether it's more beneficial to inline it or
not.  The instructions with large immediate are also not very friendly
to modern architecture yop caches and that up more space there.

But confirmed.

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

end of thread, other threads:[~2020-07-13  8:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-12 17:02 [Bug middle-end/96175] New: Failure to optimize memory stores of double literals properly gabravier at gmail dot com
2020-07-12 17:10 ` [Bug target/96175] " pinskia at gcc dot gnu.org
2020-07-13  8:15 ` rguenth 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).