logoalt Hacker News

codedokodeyesterday at 6:21 PM1 replyview on HN

Modifying a constant in code might make sense because it saves several precious bytes of variable storage.


Replies

inigyouyesterday at 7:31 PM

No, it might make sense because it saves precious memory bandwidth as well as uop count. This code wasn't called that often, generally once per drawing operation, but I don't like being uselessly wasteful - that mindset is how software got so bloated.

Your program is either front-end stalled by uop count or instruction cache latency, or back-end bound by memory bandwidth or ALU throughput or a serial dependency chain. It doesn't matter which is the bottleneck for this case, because inlining constants improves most of the above!

show 1 reply