Re:When Compiler Optimizations Hurt Performance
by pjmlp on Tuesday October 21, 2025 @09:11AM
(#45655328)
Worse is the cargo cult of "write this way because it is faster", without any measurements.
Only because it used to be true in the past, someone told it was so during a coffee break, or it appeared in some computer related article.
Re:When Compiler Optimizations Hurt Performance
by superblas on Tuesday October 21, 2025 @09:24AM
(#45655483)
Agreed. As an embedded software engineer new to the field I’ve seen senior engineers with over ten years of experience complain when division by a compile time constant (even by a power of two) is used in code instead of multiplication or bit shifting on our cortex-m7 mcu running at 600MHz
It’s also a reminder that compilers aren’t magic and optimizers aren’t all-knowing.
People have a tendency to ascribe magical properties to anything they don’t understand. Compilers and optimizers more so.
Measure before and after any optimization. You’d be surprised at what does and doesn’t improve efficiency.
Today’s CPUs are more complex than a human can understand.
Measure twice, cut once.