diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64326df830a..d2342b12b69 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-04 Richard Sandiford + + * fold-const.c (fold_ternary_loc): Check tree_fits_uhwi_p before + using tree_to_uhwi. + 2018-01-04 Richard Sandiford * tree-ssa-forwprop.c (is_combined_permutation_identity): Allow diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 46490cad0bc..521c2dc09ce 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11643,7 +11643,9 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, if (TREE_CODE (arg0) == VECTOR_CST && (type == TREE_TYPE (TREE_TYPE (arg0)) || (TREE_CODE (type) == VECTOR_TYPE - && TREE_TYPE (type) == TREE_TYPE (TREE_TYPE (arg0))))) + && TREE_TYPE (type) == TREE_TYPE (TREE_TYPE (arg0)))) + && tree_fits_uhwi_p (op1) + && tree_fits_uhwi_p (op2)) { tree eltype = TREE_TYPE (TREE_TYPE (arg0)); unsigned HOST_WIDE_INT width = tree_to_uhwi (TYPE_SIZE (eltype));