15

Everytime I think I'm smarter than the compiler, I'm... absolutely not smarter than the compiler lol

Comments
  • 6
    Yes, when I started reading about gcc optimizations I was floored about how much I did not understand about optimization. Especially with the architectures changing over time.

    Write all the code and let Compiler sort it out.
  • 1
    @Demolishun So true. What sparked this whole rant was a showdown of sorts on godbolt and believe it or not, the dumbest, "worst" and "least optimized" version of the function was the best optimized one

    So much for for my clever code and `unsafe{std::instrinsics::ctlz_nonzero(..)}`
  • 6
    I know I'm a noob, but this reminded me of the time where I was writing some code in Java and invoked the garbage collector from code. Eclipse threw me a warning saying "Don't try to be smarter than the JVM, delete this line." I guffawed straight for a minute and brought over my colleague and then we laughed at it together.

    I deleted the line, though.
  • 2
    you may be smarter than the compiler.... but: the compiler is better at being dumb than you are at being smart.
Add Comment