public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -march=x86_64 -mtune=generic question
@ 2022-05-25 18:58 Tom Kacvinsky
  2022-05-26  7:11 ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Kacvinsky @ 2022-05-25 18:58 UTC (permalink / raw)
  To: gcc-help

Perhaps this is a question for the gcc development list, but I thought
I'd try here first.

I am trying to figure out why GCC 12.1 generated object code is
executing a hair slower than GCC 8.3.0 generated object code.

I did run gcc with -fverbose-asm and -S, examined the assembly, and saw
that -march=x86_64 -mtune=generic was used for compilation options.

Reading the documentation. I see that -mtune=generic can change from GCC
release to release based on the most prevalent processors in use at the
time.

I did poke around at the gcc source code and (gcc/config/i386/*) to see
if I could figure out what changed from release to release and admit defeat.

Does anyone have a quick rundown on what would have changed between GCC
8.3.0 and 12.1.0 in terms of what -mtune=generic does for optimizations?

Thanks,

Tom

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

* Re: -march=x86_64 -mtune=generic question
  2022-05-25 18:58 -march=x86_64 -mtune=generic question Tom Kacvinsky
@ 2022-05-26  7:11 ` Andrew Haley
  2022-05-26 10:13   ` Tom Kacvinsky
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Haley @ 2022-05-26  7:11 UTC (permalink / raw)
  To: gcc-help

On 5/25/22 19:58, Tom Kacvinsky via Gcc-help wrote:
> Does anyone have a quick rundown on what would have changed between GCC
> 8.3.0 and 12.1.0 in terms of what -mtune=generic does for optimizations?

There was a vast amount of work done on many things, so we can't easily
say what affected you. Generally speaking GCC gets better release to release,
but bear in mind that compiler optimizations are often based on heuristics.
That is to say, they make code better on average, but sometimes they might
make things worse. If your degradation is slight overall, there might be an
actual regression in the compiler, but chances are you just got unlucky.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


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

* Re: -march=x86_64 -mtune=generic question
  2022-05-26  7:11 ` Andrew Haley
@ 2022-05-26 10:13   ` Tom Kacvinsky
  2022-05-26 11:05     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Kacvinsky @ 2022-05-26 10:13 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

On Thu, May 26, 2022 at 3:12 AM Andrew Haley via Gcc-help <
gcc-help@gcc.gnu.org> wrote:

> On 5/25/22 19:58, Tom Kacvinsky via Gcc-help wrote:
> > Does anyone have a quick rundown on what would have changed between GCC
> > 8.3.0 and 12.1.0 in terms of what -mtune=generic does for optimizations?
>
> There was a vast amount of work done on many things, so we can't easily
> say what affected you. Generally speaking GCC gets better release to
> release,
> but bear in mind that compiler optimizations are often based on heuristics.
> That is to say, they make code better on average, but sometimes they might
> make things worse. If your degradation is slight overall, there might be an
> actual regression in the compiler, but chances are you just got unlucky.
>


I did have an idea of diffing the gcc/config/i386 folder between the 8.3
and 12.1
 release tags, but that gave a _lot_ of stuff about support for AVX512.

A colleague of mine reminded me of this thread:

slowdown with -std=gnu18 with respect to -std=c99

So I checked what the default C standard for GCC 8.3.0 is (gnu11) and 12.1.0
(gnu17).  So I used -std=c99 with the GCC 12.1 build of our code, and things
went back to normal (and sometimes a teensy bit better).

For what it's worth, the performance issue was death by a thousand cuts -
there
was no glaring hotspot, and least by looking at callgrind output.

Tom

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

* Re: -march=x86_64 -mtune=generic question
  2022-05-26 10:13   ` Tom Kacvinsky
@ 2022-05-26 11:05     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2022-05-26 11:05 UTC (permalink / raw)
  To: Tom Kacvinsky; +Cc: Andrew Haley, gcc-help

On Thu, 26 May 2022 at 11:15, Tom Kacvinsky via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> A colleague of mine reminded me of this thread:
>
> slowdown with -std=gnu18 with respect to -std=c99
>
> So I checked what the default C standard for GCC 8.3.0 is (gnu11) and 12.1.0
> (gnu17).  So I used -std=c99 with the GCC 12.1 build of our code, and things
> went back to normal (and sometimes a teensy bit better).

N.B. the issue in that thread was the difference between -std=cNN and
-std=gnuNN, not the changes in the value of NN.

So you should be able to use -std=c17 and get the same performance as -std=c99.

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

end of thread, other threads:[~2022-05-26 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 18:58 -march=x86_64 -mtune=generic question Tom Kacvinsky
2022-05-26  7:11 ` Andrew Haley
2022-05-26 10:13   ` Tom Kacvinsky
2022-05-26 11:05     ` Jonathan Wakely

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