Add tree_fits_uhwi_p tests to BIT_FIELD_REF folder
commit760c6bc3f82b046b27f6f82fc26bb6f4cc6cf68a
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Jan 2018 18:05:10 +0000 (4 18:05 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Jan 2018 18:05:10 +0000 (4 18:05 +0000)
tree00a25a55d43f38ef6035f5a5034d458d1e0973de
parent92a3e4336950ccb33b0f4fb37bc48b34592b1662
Add tree_fits_uhwi_p tests to BIT_FIELD_REF folder

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.

2018-01-04  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* fold-const.c (fold_ternary_loc): Check tree_fits_uhwi_p before
using tree_to_uhwi.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256258 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/fold-const.c