[PATCH] x86: actually implement .noopt

Jan Beulich jbeulich@suse.com
Mon Jan 8 09:03:47 GMT 2024


On 08.01.2024 09:57, Fangrui Song wrote:
> On Sun, Jan 7, 2024 at 11:48 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 08.01.2024 02:18, Fangrui Song wrote:
>>> On Fri, Jan 5, 2024 at 12:31 AM Jan Beulich <jbeulich@suse.com> wrote:
>>>>
>>>> For quite some time we've had support for -O command line options. With
>>>> that ignoring at least .noopt isn't really a good idea.
>>>>
>>>> Re-purpose the optimize-3 test for testing this directive's effect as
>>>> well.
>>>>
>>>> As to the doc addition - this uses the same text as is there for the
>>>> {nooptimize} pseudo-prefix, despite me not being convinced of the "size"
>>>> part being fully accurate there (and hence also here).
>>>> ---
>>>> I haven't been able to find any applicable documentation for other
>>>> (perhaps legacy) assemblers' support of .noopt (and .optim). An option
>>>> to also handle .optim would be to
>>>> - restore previously saved settings (if optimization was enabled on the
>>>>   command line),
>>>> - enable a pre-determined level of optimization if optimization was not
>>>>   enabled on the command line.
>>>> Thoughts?
>>>
>>> Interesting. This is from
>>> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b6f8c7c45229a8a5405079e586bfbaad396d2cbe
>>> ("x86: Add -O[2|s] assembler command-line options").
>>
>> I'm confused by your reply: How is the above related (other than being,
>> as stated, the reason for wanting to no longer ignore .noopt)?
> 
> Sorry, I did not realize that .optim and .noopt have been available
> (bug ignored) for a long time (since 1992)...
> 
> % grep 'optim and' gas/ChangeLog-9295
>         (md_pseudo_table): Ignore .optim and .noopt.
> 
> Thomas G. Szymanski, "Assembling Code for Machines with Span-Dependent
> Instructions", April 1978, coined the term "span-dependent
> instructions".
> _AIX PS/2 and System/370 Programming Tools and Interfaces_ refers to
> the term and defines .optim and .noopt
> 
>> These directives are used to turn off and ¦ ¦ .optim ¦ on span optimizations.
> 
> There is no more information. It's possible that AIX PS/2 and
> System/370 only use .optim/.noopt for branches, a restricted form of
> the general span-dependent expressions.
> Hmm, I cannot find information about the directives in other assemblers.
> 
> Should gas invent a new directive, given that optimize_encoding does
> other kinds of optimizations, unrelated to "span" (which is related to
> an address per the paper "if that instruction's operand has an address
> between m+a and m+b")

It is precisely this uncertainty which made me deal with .noopt only,
leaving .optim alone. Personally I consider ignoring directives quite
bad: Either we understand what the programmer wants, or we don't. As
a result an alternative to my (partial) proposal would be to simply
purge the two lines from i386's pseudo table. Specifically here,
ignoring a request to do optimization is possibly okay-ish, but
ignoring a request to suppress some/all optimization clearly isn't.

Jan


More information about the Binutils mailing list