aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const-call.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-02-06 10:16:19 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-02-06 10:16:19 +0100
commit4763581763de6049c938ea7129d738d497004a06 (patch)
tree36db92da41720345c8b90ec4dd599bb527a46a17 /gcc/fold-const-call.c
parentce4321c918aa0d17ecd7da6c3deb43524b1729cf (diff)
downloadgcc-4763581763de6049c938ea7129d738d497004a06.zip
gcc-4763581763de6049c938ea7129d738d497004a06.tar.gz
gcc-4763581763de6049c938ea7129d738d497004a06.tar.bz2
re PR middle-end/89210 (ICE tree check: expected integer_cst, have real_cst in to_wide, at tree.h:5600)
PR middle-end/89210 * fold-const-call.c (fold_const_vec_convert): Pass true as last operand to new_unary_operation only if both element types are integral and it isn't a widening conversion. Return NULL_TREE if new_unary_operation failed. * c-c++-common/builtin-convertvector-2.c: New test. From-SVN: r268573
Diffstat (limited to 'gcc/fold-const-call.c')
-rw-r--r--gcc/fold-const-call.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c
index 439043a..702c8b4 100644
--- a/gcc/fold-const-call.c
+++ b/gcc/fold-const-call.c
@@ -665,8 +665,17 @@ fold_const_vec_convert (tree ret_type, tree arg)
&& SCALAR_FLOAT_TYPE_P (TREE_TYPE (ret_type)))
code = FLOAT_EXPR;
+ /* We can't handle steps directly when extending, since the
+ values need to wrap at the original precision first. */
+ bool step_ok_p
+ = (INTEGRAL_TYPE_P (TREE_TYPE (ret_type))
+ && INTEGRAL_TYPE_P (TREE_TYPE (arg_type))
+ && (TYPE_PRECISION (TREE_TYPE (ret_type))
+ <= TYPE_PRECISION (TREE_TYPE (arg_type))));
tree_vector_builder elts;
- elts.new_unary_operation (ret_type, arg, true);
+ if (!elts.new_unary_operation (ret_type, arg, step_ok_p))
+ return NULL_TREE;
+
unsigned int count = elts.encoded_nelts ();
for (unsigned int i = 0; i < count; ++i)
{