public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96252] New: mis-optimization where identical functions have very different codegen since gcc 10
@ 2020-07-20 15:02 wjwray at gmail dot com
  2020-07-20 17:32 ` [Bug c++/96252] " wjwray at gmail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: wjwray at gmail dot com @ 2020-07-20 15:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96252
           Summary: mis-optimization where identical functions have very
                    different codegen since gcc 10
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wjwray at gmail dot com
  Target Milestone: ---

(Stumbled on this odd effect while examining codegen for operator<=>)

The reduced sample compiles c++11 and up (std version likely irrelevant)
with the different codegen occurring since GCC 10.

Two identical functions:

  bool cmp_x(cmp l, cmp r) noexcept {
      return std::lexicographical_compare(begin(l),end(l)
                                         ,begin(r),end(r)); }
  bool cmp_y(cmp l, cmp r) noexcept {
      return std::lexicographical_compare(begin(l),end(l)
                                         ,begin(r),end(r)); }

generate very different code for cmp = array<int,64> at -O2 and -O3.

The first is looping, the second has much longer unrolled codegen.
My benchmarks show 40% difference in runtime, quick-bench shows 30%. 

Compiler Explorer https://godbolt.org/z/97box6
Quick-bench 1.3x https://quick-bench.com/q/480qkw1sP4OWOH6JBxsm-J_9uOk

(Adding -fno-inline may provide a clue.)

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

end of thread, other threads:[~2024-05-15  7:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 15:02 [Bug c++/96252] New: mis-optimization where identical functions have very different codegen since gcc 10 wjwray at gmail dot com
2020-07-20 17:32 ` [Bug c++/96252] " wjwray at gmail dot com
2020-07-21  6:57 ` [Bug ipa/96252] " rguenth at gcc dot gnu.org
2020-07-21  6:58 ` [Bug ipa/96252] [10/11 Regression] " rguenth at gcc dot gnu.org
2020-07-23  6:51 ` rguenth at gcc dot gnu.org
2021-02-14 23:16 ` hubicka at gcc dot gnu.org
2021-02-15 14:40 ` hubicka at ucw dot cz
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-11-22  6:42 ` [Bug ipa/96252] [10/11/12 " pinskia at gcc dot gnu.org
2022-06-28 10:41 ` [Bug ipa/96252] [10/11/12/13 " jakub at gcc dot gnu.org
2023-07-07 10:37 ` [Bug ipa/96252] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-05-15  7:12 ` [Bug ipa/96252] [11/12/13/14/15 " pinskia at gcc dot gnu.org
2024-05-15  7:20 ` pinskia at gcc dot gnu.org
2024-05-15  7:41 ` jakub 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).