public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111558] New: RISCV: shrink-wrapper optimization question
@ 2023-09-23 21:00 alexey.lapshin at espressif dot com
  2023-09-23 21:17 ` [Bug rtl-optimization/111558] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: alexey.lapshin at espressif dot com @ 2023-09-23 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111558
           Summary: RISCV: shrink-wrapper optimization question
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexey.lapshin at espressif dot com
                CC: manolis.tsamis at vrull dot eu
  Target Milestone: ---

Created attachment 55977
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55977&action=edit
shrink-synthetic-example.c

When I was studying shrink-wrapping behavior, I discovered something strange
code generation.

See the code and assembly at https://godbolt.org/z/P3WfTszYn

Every branch has the same save/restore callee-saved registers.
Therefore, the shrink-wrapping optimization may reduce the speed of the
function when input parameters are not zero...

I understand that this is not a synthetic code snippet... 

But may this code generation be reproduced in real code (without asm inlining)?

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

* [Bug rtl-optimization/111558] RISCV: shrink-wrapper optimization question
  2023-09-23 21:00 [Bug c/111558] New: RISCV: shrink-wrapper optimization question alexey.lapshin at espressif dot com
@ 2023-09-23 21:17 ` pinskia at gcc dot gnu.org
  2023-09-26 13:19 ` mxlol233 at outlook dot com
  2023-09-26 13:26 ` mxlol233 at outlook dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-23 21:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>But may this code generation be reproduced in real code (without asm inlining)?


It could in theory but I highly doubt it since most of the time the code blocks
are not written in such a way they would happen this way where they are
independent and such. Maybe initialization code might be done this way but that
code is usually only executed once so the speed will not have a huge impact ...

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

* [Bug rtl-optimization/111558] RISCV: shrink-wrapper optimization question
  2023-09-23 21:00 [Bug c/111558] New: RISCV: shrink-wrapper optimization question alexey.lapshin at espressif dot com
  2023-09-23 21:17 ` [Bug rtl-optimization/111558] " pinskia at gcc dot gnu.org
@ 2023-09-26 13:19 ` mxlol233 at outlook dot com
  2023-09-26 13:26 ` mxlol233 at outlook dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mxlol233 at outlook dot com @ 2023-09-26 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Xiao Ma <mxlol233 at outlook dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mxlol233 at outlook dot com

--- Comment #2 from Xiao Ma <mxlol233 at outlook dot com> ---
For this piece of code, LLVM seems to be a bit concise: during the pass of
Prologue/Epilogue Insertion & Frame Finalization, it only inserts sd/ld blocks
in the entry and exit BB:

https://godbolt.org/z/qxdrMKc46

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

* [Bug rtl-optimization/111558] RISCV: shrink-wrapper optimization question
  2023-09-23 21:00 [Bug c/111558] New: RISCV: shrink-wrapper optimization question alexey.lapshin at espressif dot com
  2023-09-23 21:17 ` [Bug rtl-optimization/111558] " pinskia at gcc dot gnu.org
  2023-09-26 13:19 ` mxlol233 at outlook dot com
@ 2023-09-26 13:26 ` mxlol233 at outlook dot com
  2 siblings, 0 replies; 4+ messages in thread
From: mxlol233 at outlook dot com @ 2023-09-26 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Xiao Ma <mxlol233 at outlook dot com> ---
(In reply to Xiao Ma from comment #2)
> For this piece of code, LLVM seems to be a bit concise: during the pass of
> Prologue/Epilogue Insertion & Frame Finalization, it only inserts sd/ld
> blocks in the entry and exit BB:
> 
> https://godbolt.org/z/qxdrMKc46

On the contrary, GCC emits sd/ld blocks for each of BB, in the pro_and_epilogue
pass:

https://godbolt.org/z/vY4M71snz

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

end of thread, other threads:[~2023-09-26 13:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-23 21:00 [Bug c/111558] New: RISCV: shrink-wrapper optimization question alexey.lapshin at espressif dot com
2023-09-23 21:17 ` [Bug rtl-optimization/111558] " pinskia at gcc dot gnu.org
2023-09-26 13:19 ` mxlol233 at outlook dot com
2023-09-26 13:26 ` mxlol233 at outlook dot com

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