Hacker News new | ask | show | jobs
by chrisseaton 3237 days ago
In a moderately sophisticated compiler, yes they should be the same thing.

The difference in the two is that the latter has to produce the original value, presumably by keeping it in a temporary variable. A compiler which looks at all the code in a function when optimising, rather than just blindly emitting code for each individual operation, will see that the value is not needed, and delete the temporary.

I guess cc65 is a bit more basic. Compilers for more unusual embedded environments are often a bit more basic, hence the general advice for the embedded context.

I think you could probably fix the compiler for this trivial case in the time it takes you to write down the advice though.