If your starting assumption is that you are smarter than the compiler, then your code should run the fastest as-is, and any compiler optimization flags could only make it slower.
-
This Tweet is unavailable.
-
-
Replying to @stefan_3d @dgmdavid and
That's not at all how compilers work. If you do not turn optimizations on, it will store and load every value to and from the stack on every line. There is no way to write performance oriented code without turning optimizations on unless you use inline ASM.
2 replies 0 retweets 18 likes -
Replying to @cmuratori @dgmdavid and
It will load and store from the stack when you're using variable that live on the stack - just as you wrote it. Try the register keyword and you'll see those loads and stores disappear in -O0 - because now your code tells it to not use the stack.
2 replies 0 retweets 0 likes -
Replying to @stefan_3d @dgmdavid and
Dude, this is getting really tiring. You literally have no idea what you're talking about, and everything you've said in this thread is wrong. Here is a Godbolt of CLANG 10. Tell me again how it removes all the stack stores when you put register in there?https://godbolt.org/z/POwozW
1 reply 1 retweet 5 likes -
Replying to @cmuratori @stefan_3d and
The reason is because REGISTER DOESN'T EXIST ANYMORE. It was removed from the spec. Even I know that, and I don't care about the C++ spec. It was deprecated a long time ago. Most compilers just ignore it now, it doesn't actually do anything.
1 reply 0 retweets 1 like -
Replying to @cmuratori @dgmdavid and
Of course it’s deprecated. It turned out that compilers were much better at assigning registers than programmers were.
1 reply 0 retweets 0 likes -
Replying to @stefan_3d @cmuratori and
I wasn’t recommending anyone use -O0. My point was that anyone using -O2 is already relying on compiler optimizations and can’t claim all performance is solely their own work. If that were the case, then we would not see any performance differences between compilers.
1 reply 0 retweets 0 likes -
Replying to @stefan_3d @dgmdavid and
I give up, dude. Your original claim was that if people wrote high-performance C++ code they could use -O0, and the fact that they don't is evidence that the "compiler knows better than they do." I've given you TONS of evidence that's blatantly false.
1 reply 0 retweets 11 likes -
Replying to @cmuratori @stefan_3d and
And it's pretty clear you don't know what you're talking about, because you keep bringing things up, I show you explicit evidence you're wrong, and then you go talk about something else or claim you were saying something else.
1 reply 0 retweets 8 likes
And as far "compilers are better at assigning registers than programmers", that's ALSO blatantly false. Compilers _suck_ at assigning registers. The only reason they're even remotely passable these days is because the number of registers increased.
-
-
This Tweet is unavailable.
-
This Tweet is unavailable.
- Show replies
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.