e7301f5fcbfa6 required the sizes and offsets of a
BIT_FIELD_REF to be poly_uint64s rather than uhwis.

When support for predicated vector tails with BB SLP
is enabled, GIMPLE will sometimes contain statements
such as:

float _246;
vector([4,4]) float _251;
_251 =
{ _234, _236, _238, _84 }

;
246 = BIT_FIELD_REF <_251, 32, POLY_INT_CST [96, 128]>

Update an existing pattern named 'Simplify vector extracts'
to guard against invalid invocations of tree_to_uhwi
in such circumstances (by checking beforehand with
tree_fits_uhwi_p).

gcc/ChangeLog:

        * match.pd: Require the offset and size parameters of
        a BIT_FIELD_REF to fit type unsigned HOST_WIDE_INT
        before attempting to convert them.

---
 gcc/match.pd | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index f164ec59100..db7f4374bbf 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -9969,6 +9969,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (BIT_FIELD_REF CONSTRUCTOR@0 @1 @2)
  (if (VECTOR_TYPE_P (TREE_TYPE (@0))
       && tree_fits_uhwi_p (TYPE_SIZE (type))
+      && tree_fits_uhwi_p (@1)
+      && tree_fits_uhwi_p (@2)
       && ((tree_to_uhwi (TYPE_SIZE (type))
           == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0)))))
           || (VECTOR_TYPE_P (type)
-- 
2.43.0

Reply via email to