3 ms·
I'll admit to not being super great at getting down into the nitty gritty with internals of compilers. Are you talking about some sort of IR? Because if we're t
by Kamq 2y ago
I'll admit to not being super great at getting down into the nitty gritty with internals of compilers. Are you talking about some sort of IR? Because if we're talking about the output, mutation definitely happens.
Checking on godbolt, there's definitely mutation at least sometimes. Using gcc 13.2, I get the following output.
j += i; becomes:
movl -4(%rbp), %eax // move i into %eax
addl %eax, -8(%rbp) // add i to j
With i++ becoming:
addl $1, -4(%rbp). // add 1 to i
If your example is IR, do you happen to know how it crunches everything "back down" to mutability? Does it just check that the previous value of i and j were never used and use the same registers as an optimization?