12/11/2025
at
11:06:40 PM
As impressive as this analysis is by the compiler, I shudder to think how much time the compiler spends doing these kinds of optimizations. In my opinion, a better architecture would be for the compiler to provide a separate analysis tool that suggests source level changes for these kinds of optimizations. It could alert you that the loop could be replaced with a popcount (and optionally make the textual replacement in the source code for you). Then you pay the cost of the optimization once and have the benefit of clarity about what your code _actually_ runs at runtime instead of the compiler transparently pulling the rug out from underneath you when run with optimizations.Side note: many years ago I wrote the backend for a private global surveillance system that has almost surely tracked the physical location of anyone reading this. We could efficiently track how often a device had been seen at a location in the prior 64 (days|weeks|months) in just 192 bytes and use popcount to compute the value. I am not proud that I built this.
by thefaux
12/12/2025
at
9:02:19 AM
The issue is that many optimization opportunities only appear after monomorphization, inlining, de-virtualization, etc. etc.Not that you couldn't do source level analysis as you suggest... it just wouldn't be effective in many cases.
It would also be 'unstable' in the sense that it might depend on architecture, etc.
by Quekid5
12/12/2025
at
2:03:02 AM
Especially in languages that allow generic programming, the right thing to do will be context dependent.
by adgjlsfhk1