RE: [PATCH v3 3/6] x86/gsseg: make asm_load_gs_index() take an u16

H. Peter Anvin
2022-10-15T02:42:28Z

On October 14, 2022 5:28:25 AM PDT, David Laight <David.Laight@ACULAB.COM> wrote:
>From: Xin Li
>> Sent: 13 October 2022 21:02
>>
>> From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
>>
>> Let gcc know that only the low 16 bits of load_gs_index() argument
>> actually matter. It might allow it to create slightly better
>> code. However, do not propagate this into the prototypes of functions
>> that end up being paravirtualized, to avoid unnecessary changes.
>
>Using u16 will almost always make the code worse.
>At some point the value has to be masked and/or extended
>to ensure an out of range value doesn't appear in
>a register.
>
> David
>
>-
>Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
>Registration No: 1397386 (Wales)
>
>

Is that a general statement or are you actually invoking it in this case? This is about it being a narrowing input, *removing* such constraints.