You probably compiled without optimization (-O). What you see is a direct, naive translation of an intermediate view. Such fragments are usually related to the fact that the value is stored in a local variable, in this case 0xf8 (% rbp). Then the value is used immediately after that, so it loads it into the% rax register again. The optimizer will find that saving from% rax only to restore back to the same register is redundant and completely deletes the sequence. If all stages of optimization do not work, at least the eye will determine these two instructions in a row.
If you really turned on optimization, this is really strange, but can be explained if you place a large (but not too large) sequence. There are still many cases where something clearly suboptimal will be generated, but nothing is so contradictory.
source share