Re: [PATCH v4 01/17] x86/mpx: Do not use SIB index if index points to R/ESP

From: Ricardo Neri
Date: Fri Feb 24 2017 - 14:08:06 EST


On Fri, 2017-02-24 at 09:47 -0500, Nathan Howard wrote:
> Also, this code would read better with the inner test
> reversed or done first
>
> if (indx_offset < 0) {
> if (indx_offset != -EDOM)
> goto out_err;
> indx = 0;
> } else {
> indx = regs_get_register(etc...)
> }
>
> or
> if (indx_offset == -EDOM)
> indx = 0;
> else if (indx_offset < 0)
> goto err;
>
>
> Or goto out_err;
>
>
> else
> indx = regs_get_register(etc...)
>
> The compiler should generate the same code in any
> case, but either could improve reader understanding.
>
>
> Also, it may be a tweak more efficient to handle the most likely
> runtime case in the conditional stack first (whichever that may be).

The most likely case will be a positive value but I need to check for
negatives first :( I could wrap the first conditional in an "unlikely".

Thanks and BR,
Ricardo