On 01/04/2018 03:06 AM, Richard Sandiford wrote:
> The first BIT_FIELD_REF folding pattern assumed without checking that
> operands satisfy tree_fits_uhwi_p.  The second pattern does check this:
> 
>       /* On constants we can use native encode/interpret to constant
>          fold (nearly) all BIT_FIELD_REFs.  */
>       if (CONSTANT_CLASS_P (arg0)
>           && can_native_interpret_type_p (type)
>           && BITS_PER_UNIT == 8
>           && tree_fits_uhwi_p (op1)
>           && tree_fits_uhwi_p (op2))
> 
> so this patch adds the checks to the first pattern too.  This is needed
> for POLY_INT_CST bit positions.
> 
> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
> Also tested by comparing the before and after assembly output for at
> least one target per CPU directory.  OK to install?
> 
> Richard
> 
> 
> 2018-01-04  Richard Sandiford  <richard.sandif...@linaro.org>
> 
> gcc/
>       * fold-const.c (fold_ternary_loc): Check tree_fits_uhwi_p before
>       using tree_to_uhwi.
OK.
jeff

Reply via email to