TARGET_SHIFT_TRUNCATION_MASK

Paolo Bonzini bonzini@gnu.org
Thu Jul 15 12:17:00 GMT 2010


On 07/15/2010 09:57 AM, Uros Bizjak wrote:
> Hello!
>
> I was playing a bit with TARGET_SHIFT_TRUNCATION_MASK on x86 in the
> hope that redundant masking would get eliminated from:
>
> int test (int a, int c)
> {
> 	return a<<  (c&  0x1f);
> }
>
> The macro was defined as:
>
> +/* Implement TARGET_SHIFT_TRUNCATION_MASK.  */
> +static unsigned HOST_WIDE_INT
> +ix86_shift_truncation_mask (enum machine_mode mode)
> +{
> +  switch (mode)
> +    {
> +    case QImode:
> +    case HImode:
> +    case SImode:
> +      return 31;
> +
> +    case DImode:
> +      if (TARGET_64BIT)
> +	return 63;
> +
> +    default:
> +      return 0;
> +    }
> +}
>
> However, I was not able to get rid of the masking "and".

FWIW, the reason the hook is not implemented on x86 is that some 
variants of bsf/bsr (I think with memory source) do not honor the 
truncation.

Paolo



More information about the Gcc mailing list