Do you?

Do you?

Attached: gcc.png (200x200, 5K)

Other urls found in this thread:

gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
twitter.com/SFWRedditImages

yeah dude
sure

-Os

-O2 is for normal people

For release builds and benchmarking, yes

-flto makes a huge difference in my experience.

no. kernel optimizations. -O3 does nothing and invites problems.

>-O3 does nothing
for all of the small projects I've created and tested it on, -O3 was a significant speed boost.
I know they say that it may reduce performance, but I've never written a piece of code where that happened.
-Wl,-O1 also gave me a speed boost.
>invites problems
the only case where it will invite problems is if your code contains undefined behavior. At worst, it'll help you know that your code contains errors.
I've never actually seen a confirmed case of this, but the gentoo people claim it's a problem. supposedly it broke pyblake a few months ago, but I don't know if that was confirmed.

>small project
yes, good code will react well.
>the only case where it will invite problems is if your code contains undefined behavior.
i did install gentoo. Gnome is entirely built based on undefined behavior.

set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-OFast -march=native")

Attached: 1510417240272.png (800x800, 84K)

>>invites problems
>the only case where it will invite problems is if your code contains undefined behavior.
It'll also mess up floating point code that needs maximum accuracy. I think it assumes floating point math is associative which always isn't the case but can usually be okay

even in (most) games fastmath is perfectly fine, only mathematics needs super-precise fps

remember to turn on march=native for possible alignment optimizations and AVX vectorization

>good code will react well
a lot of the code in my early days was pretty bad. -O3 still seemed to help. One project was so bad that rewriting it gave about a 2x speed boost.
>Gnome is entirely built based on undefined behavior
use a well written and portable DE like XFCE then.
>It'll also mess up floating point code that needs maximum accuracy
no if -O3 fucks with your floating point precision, then that's a bug in GCC. -O3 should abide by the IEEE 754 floating point standard.
-Ofast will fuck with your floating point precision because it enabled -ffast-math though.
>even in (most) games fastmath is perfectly fine
I've heard devs say that it can cause flickering or other graphics weirdness.
>remember to turn on march=native for possible AVX vectorization
this will only take effect if your optimization level is -O3, which enabled -ftree-vectorize

Recently I fell for the profile guided optimization meme. Shit's insanely fast sometimes.

No - in real, sizable programs, -O2 is usually faster, since it fits into the cache, and that's way more important today than skipping a fucking loop condition check.
Modern processors are complex machines that merely pretend to be x86.

>-O2 is usually faster, since it fits into the cache
it really depends on the structure of your code. If you're doing audio mixing, then the majority of your code is going to be in small loops, which will still fit in the trace cache when vectorized with SSE/AVX (-ftree-vectorize, which is enabled with -O3).
There are also some cases where the optimizations enabled by -O3 won't even increase the size of your code. a very small function being inlined can reduce the trace cache space being used. a function that vectorizes nicely can also be smaller than its scalar equivalent.

>Modern processors are complex machines that merely pretend to be x86
they have a billion instruction set extensions on top of that x86 base.

-Ofast, retards

if your program doesn't make heavy use of floating point calculations and isn't written in fortran, -Ofast won't do much.

even for benchmarking I've never gotten a worthwhile boost with -O3
but most of my experience is on non-x86/ARM platforms where GCC is lackluster at best anyway

>Gnome is entirely built based on undefined behavior.
Dohoho.
Unless you are serious, in which case please elaborate.

how hard is it to setup say for a browser/qtwebengine?

I only used it in visual studio, can't help you here.

-Og for debug builds.
-O3 or -Os for release. If the project is sufficiently small, I do a unity build.

does anyone know an easy way to convert some binary into a static one?
I'd like to have several versions of ffmpeg installed on my system but I can have only one at a time.
I wish there was a way to create a static build that I could place somewhere in my path and rename it to something like ffmpeg-custom or something.
anyone know how to do that? I'm under arch if it makes any difference.....

Attached: 1519955576470.jpg (1078x1078, 137K)

you can build ffmpeg and link it statically, why not
just use the relevant configure flag, try ./configure --help

"-march=native -Ofast" master race reporting in

Attached: tfw to inteligent.jpg (419x546, 75K)

-O2 -march=native is all you need
-O2 -mtune=TARGET_ARCH when building for an incompatible march

-flto -O2 -finline-functions -static -s
Patrician optimization flags.
All others are nigger-tier.

>the only case where it will invite problems is if your code contains undefined behavior. At worst, it'll help you know that your code contains errors.
Optimization flags can fuck concurrent algorithms up by reordering instructions. If that's UB then all programming is potentially UB.

C really needs a standard way of saying "don't optimise this".

Long running memes about memory clearing being removed by the compiler is horseshit. There are pragmas, but that's non standard and therefore unhelpful.

That's what volatile is for, isn't it?

>fuck concurrent algorithms up by reordering instructions
And you deserve every bit of it. Use atomics you fucking idiot.
If the compiler is allowed to break your algorithm by reordering instructions, you fucked up, not the compiler.

Piss easy

based

this

-Ofast

>gcc headshot
>system down

do this in embedded systems and you will be instantly fired and you won't find another job

-O9 -funroll-loops

Attached: This dude literally killed himself as a joke.jpg (300x229, 10K)

This

why?

>not -Ofast

-O3 produces bloated binaries

-Os is king

Not him but embedded compilers are fucking retarded. Had to use volatile for a global variable because it was "optimized" to a register, and I wasn't even using O3, just O2.

>write code using mpi
>the overhead of broadcasting across images after each iteration outweighs the gains

Attached: 1295621688922.jpg (186x220, 20K)

i press the build button on visual studios

And you probably ship code with debug symbols too

how do you delete debug symbols?

whats the size difference between Os and O3 ?

gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

>"only UB can fuck things up"
>"no, there's something else"
>"YOU DESERVE IT REEEEEEEEEEEEE REEEEEEEEEEEE USE YOU PIECE OF SHIT REEEEEEEEEEEEEE SMDHFN;B:CJKBNGC KNJVN FUCK OFF REEEEEEEEEEEEEEEEEEEEE"

Attached: autism.gif (480x270, 528K)

Instruction reordering is UB you fucktard.
There isn't anything else, there is only UB.

Instruction ordering* I mean.
not necessarily reordering.

Do I what?

>Want to use inline
>No idea when it will blow up code or speed it up

>if your program doesn't make heavy use of floating point calculations
check
> and isn't written in fortran
check

feels gud

Attached: 1485475881871.gif (280x196, 126K)

>-O3 -funroll-all-loops

if it's shared memory just use openMP. it also takes 2 seconds to parellilze a loop, it's literally

#pragma omp parallel for

What does this do exactly when faced with a loop that it doesn't know how many iterations it is going to do before hand?

/tmp/tmp.dnWvyZ2M3h> cat lazy_user.c
#include

int main(int argc, char **argv)
{
while(argc--)
printf("For the lazy user, next time test it yourself.\n");
return 0;
}
/tmp/tmp.dnWvyZ2M3h> gcc -O3 -funroll-all-loops -o lazy_user lazy_user.c
/tmp/tmp.dnWvyZ2M3h> ./lazy_user a
For the lazy user, next time test it yourself.
For the lazy user, next time test it yourself.
/tmp/tmp.dnWvyZ2M3h>gdb -batch -ex 'file lazy_user' -ex 'disassemble main'
>> Output too large, seems like you have to do it yourself.

>all programs are UB with no exception
ouch mang

It only fucks up if you fail to use the proper memory ordering that is defined in the c11 standard.

All programs that rely on instruction ordering where instruction ordering is undefined are UB, yes.
As long as SINGLE THREADED behavior (as defined by the standard) is preserved, compilers are allowed to order instructions however they want.
If you're using multiple threads, you need to use atomics to properly synchronize things. This isn't a difficult thing to understand m8, maybe you're just retarded.
I recommend you give up programming and stop touching computers.

Also, both C11 and C++11 have atomic types and operations defined in their respective standards, so you have no excuse.