News for hackers. Stuff that matters.
Re:The gold standard of optimization: A look under the hood ... by youarentrightjr on Sunday March 22, 2026 @06:36PM (#47482973)
> The same trick can also be used for the other direction to save a division: NewValue = OldValue >> 3; This is basically the same as NewValue = OldValue / 8; RCT does this trick all the time, and even in its OpenRCT2 version, this syntax hasn’t been changed, since compilers won’t do this optimization for you.

(emphasis mine)

Not at all true. Assuming the types are such that >> is equivalent to /, modern compilers will implement division by a power of two as a shift every single time.

Re:The gold standard of optimization: A look under the hood ... by dmitrygr on Monday March 23, 2026 @01:38AM (#47485825)
they will do it for unsigned. for signed they will do a bit more to do the same rounding as C promises
Re:The gold standard of optimization: A look under the hood ... by grumbelbart2 on Monday March 23, 2026 @08:55AM (#47488836)
Here is how that looks like:

https://godbolt.org/z/rooee4esd

Re:The gold standard of optimization: A look under the hood ... by account42 on Monday March 23, 2026 @10:25AM (#47490016)
It's unfortunate that C tied overflow behavior to the signedness of integer types.
Re:The gold standard of optimization: A look under the hood ... by mid-kid on Monday March 23, 2026 @08:20AM (#47488442)
Yeah. I'm surprised this along with the money thing are listed in the article at all. These are the sort of things you learn within the first month of writing assembly, and were widely used across the industry at the time (and times prior). The bit shifting optimization is performed by GCC even at -O0, and likely already was at the time, as it's one of the simpler optimizations to make. It's like calling "xor eax, eax" a masterful optimization tactic for clearing a register.

Looking at the macro-level optimizations like the rest of the article does is significantly more interesting.

Re:The gold standard of optimization: A look under the hood ... by ConceptJunkie on Monday March 23, 2026 @12:51PM (#47492003)
"XOR AXAX" was my license plate in the 90s.
Re:The gold standard of optimization: A look under the hood ... by dmitrygr on Monday March 23, 2026 @04:27PM (#47494657)
I had "PUSH EAX" and "BX LR" :)
Re:The gold standard of optimization: A look under the hood ... by account42 on Monday March 23, 2026 @10:23AM (#47489981)
Yeah and this can be verified with the minimum level of research you'd expect for this kind of article, e.g. by firing up compiler explorer.
Re:The gold standard of optimization: A look under the hood ... by spiffyk on Monday March 23, 2026 @12:26PM (#47491670)
That whole section is kind of weird. The mention of operator overloading also seems out of place, since the operator is not overloaded here at all.