[PATCH 4/6] x86: slightly simplify offset_in_range()

H.J. Lu hjl.tools@gmail.com
Thu Jun 17 14:46:40 GMT 2021


On Mon, Jun 14, 2021 at 3:26 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Applying a mask with all bits set (or its inverse, with hence all bits
> clear) won't alter the result (or won't trigger the warning). Re-arrange
> the code to eliminate two more of the somewhat odd (2 << width_minus_1)
> constructs.
>
> gas/
> 2021-06-XX  Jan Beulich  <jbeulich@suse.com>
>
>         * config/tc-i386.c (offset_in_range): Bail early when mask would
>         cover all bits anyway.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -2556,10 +2556,10 @@ offset_in_range (offsetT val, int size)
>      {
>      case 1: mask = ((addressT) 1 <<  8) - 1; break;
>      case 2: mask = ((addressT) 1 << 16) - 1; break;
> -    case 4: mask = ((addressT) 2 << 31) - 1; break;
>  #ifdef BFD64
> -    case 8: mask = ((addressT) 2 << 63) - 1; break;
> +    case 4: mask = ((addressT) 1 << 32) - 1; break;
>  #endif
> +    case sizeof (val): return val;
>      default: abort ();
>      }
>
>

OK.

Thanks.

-- 
H.J.


More information about the Binutils mailing list