Thanks for the reply. I'm surprised both versions don't optimise down to the exact same code, or at least the same with r2 and r3 swapped.That was with the default which I believe is -O3. Using -O2 and -O1 it's the same. Using -O0 adds quite a lot more.What optimisation level was that compiled with and does the assembler change with -O2?
To me the differences reflect the habit of gcc to precompute constants and put them in memory. These days memory is slow and compute fast; therefore, this could be viewed as bad habit dating back to early times, or not. I could be completely misunderstanding what's going on.
Statistics: Posted by ejolson — Thu Nov 20, 2025 5:29 pm