Optimizing 0-displacement jumps on i386
H. Peter Anvin
hpa@zytor.com
Wed Aug 13 18:58:56 GMT 2025
On 2025-08-11 23:07, Jan Beulich wrote:
>>
>> One more issue: a zero-offset jump may also be used to sync the prefetch
>> pipe on the CPUs that require that. For example, the Linux boot code
>> contains the following sequence:
>>
>> /* Self-modify the INT instruction. Ugly, but works. */
>> cmpb %al, 3f
>> je 1f
>> movb %al, 3f
>> jmp 1f /* Synchronize pipeline */
>> 1:
>
> Hence why I think such optimizations may not be turned on by default.
>
Yes; this really needs an opt-in as otherwise it will break existing,
valid code; preferably as a pseudo-op that can disable it on a localized
basis.
-hpa
More information about the Binutils
mailing list