Preventing x86 instruction length optimizations

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Preventing x86 instruction length optimizations

Florian Weimer
A recent GAS update to Debian (currently at 2.16.1cvs20050902-1)
changed the length of this instruction:

  adc 0(%ebx,%ecx,4),%edx

Previously, it was encoded as a four-octet sequence, now it's
equivalent to:

  adc (%ebx,%ecx,4),%edx

-- which only needs three octets.

Is this the intended behavior?  Is there any easy way to force the
long instruction encoding, short of using .byte?
Reply | Threaded
Open this post in threaded view
|

Re: Preventing x86 instruction length optimizations

Jan Beulich
>>> Florian Weimer <[hidden email]> 06.12.05 17:04:09 >>>
>A recent GAS update to Debian (currently at 2.16.1cvs20050902-1)
>changed the length of this instruction:
>
>  adc 0(%ebx,%ecx,4),%edx
>
>Previously, it was encoded as a four-octet sequence, now it's
>equivalent to:
>
>  adc (%ebx,%ecx,4),%edx
>
>-- which only needs three octets.
>
>Is this the intended behavior?

Yes. It just makes things more consistent. You will easily recognize
that already before there was no (easy) way to force gas to use a 4-byte
displacement (you're just unable to indicate you want a 'long' zero),
and that there were instruction length adjustments (relaxation) done
elsewhere.

>Is there any easy way to force the
>long instruction encoding, short of using .byte?

Not that I know of. But I also can't see the general need for something
like that...

Jan
Reply | Threaded
Open this post in threaded view
|

Re: Preventing x86 instruction length optimizations

Florian Weimer
* Jan Beulich:

>>Is there any easy way to force the
>>long instruction encoding, short of using .byte?
>
> Not that I know of. But I also can't see the general need for something
> like that...

It's useful for loop unrolling.  If you can control the instruction
lengths (so that each expanded iteration takes the same number of
bytes), you can use a computed jump to skip into the loop at the
correct position.  Otherwise, you need a cascade of conditional
branches.