https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113656
Hongtao Liu <liuhongt at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |liuhongt at gcc dot gnu.org, | |rsandifo at gcc dot gnu.org --- Comment #5 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- It hit gcc_assert in simplify_const_unary_operation when combine try to simplify (float_truncate:V4HF (float_truncate:V4SF (mem/u/c:V4DF (symbol_ref/u:DI ("*.LC4") [flags 0x2]) [0 S32 A256]))) to (float_truncate:V4HF (const_vector:V4DF [ (const_double:DF -8.4000000000000003552713678800500929355621337890625e+0 [-0x0.86666666666668p+4]) (const_double:DF -7.4000000000000003552713678800500929355621337890625e+0 [-0x0.ecccccccccccdp+3]) (const_double:DF -6.4000000000000003552713678800500929355621337890625e+0 [-0x0.ccccccccccccdp+3]) (const_double:DF -5.4000000000000003552713678800500929355621337890625e+0 [-0x0.acccccccccccdp+3]) ])) if (VECTOR_MODE_P (mode) && GET_CODE (op) == CONST_VECTOR && known_eq (GET_MODE_NUNITS (mode), CONST_VECTOR_NUNITS (op))) { gcc_assert (GET_MODE (op) == op_mode); --- hit assert here. rtx_vector_builder builder; if (!builder.new_unary_operation (mode, op, false)) return 0; unsigned int count = builder.encoded_nelts (); for (unsigned int i = 0; i < count; i++) { rtx x = simplify_unary_operation (code, GET_MODE_INNER (mode), CONST_VECTOR_ELT (op, i), GET_MODE_INNER (op_mode)); if (!x || !valid_for_const_vector_p (mode, x)) return 0; builder.quick_push (x); } return builder.build (); } The gcc_assert is added by r10-2139-g4ce6ab68894469 Author: Richard Sandiford <richard.sandif...@arm.com> Date: Mon Jul 29 08:40:21 2019 +0000 Implement more rtx vector folds on variable-length vectors This patch extends the tree-level folding of variable-length vectors so that it can also be used on rtxes. The first step is to move the tree_vector_builder new_unary/binary_operator routines to the parent vector_builder class (which in turn means adding a new template parameter). The second step is to make simplify-rtx.c use a direct rtx analogue of the VECTOR_CST handling in fold-const.c. 2019-07-29 Richard Sandiford <richard.sandif...@arm.com> gcc/ * vector-builder.h (vector_builder): Add a shape template parameter. (vector_builder::new_unary_operation): New function, generalizing the old tree_vector_builder function. (vector_builder::new_binary_operation): Likewise. (vector_builder::binary_encoded_nelts): Likewise. * int-vector-builder.h (int_vector_builder): Update template parameters to vector_builder. (int_vector_builder::shape_nelts): New function. * rtx-vector-builder.h (rtx_vector_builder): Update template parameters to vector_builder. (rtx_vector_builder::shape_nelts): New function. (rtx_vector_builder::nelts_of): Likewise. (rtx_vector_builder::npatterns_of): Likewise. (rtx_vector_builder::nelts_per_pattern_of): Likewise. * tree-vector-builder.h (tree_vector_builder): Update template parameters to vector_builder. (tree_vector_builder::shape_nelts): New function. (tree_vector_builder::nelts_of): Likewise. (tree_vector_builder::npatterns_of): Likewise. (tree_vector_builder::nelts_per_pattern_of): Likewise. * tree-vector-builder.c (tree_vector_builder::new_unary_operation) (tree_vector_builder::new_binary_operation): Delete. (tree_vector_builder::binary_encoded_nelts): Likewise. * simplify-rtx.c: Include rtx-vector-builder.h. (distributes_over_addition_p): New function. (simplify_const_unary_operation) (simplify_const_binary_operation): Generalize handling of vector constants to include variable-length vectors. (test_vector_ops_series): Add more tests. before that commit, it only assert for GET_MODE_NUNITS /* Simplification and canonicalization of RTL. */ @@ -1753,27 +1754,23 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, if (VECTOR_MODE_P (mode) && GET_CODE (op) == CONST_VECTOR) { - unsigned int n_elts; - if (!CONST_VECTOR_NUNITS (op).is_constant (&n_elts)) - return NULL_RTX; - - machine_mode opmode = GET_MODE (op); - gcc_assert (known_eq (GET_MODE_NUNITS (mode), n_elts)); - gcc_assert (known_eq (GET_MODE_NUNITS (opmode), n_elts)); + gcc_assert (GET_MODE (op) == op_mode); - rtvec v = rtvec_alloc (n_elts); - unsigned int i; + rtx_vector_builder builder; + if (!builder.new_unary_operation (mode, op, false)) + return 0; - for (i = 0; i < n_elts; i++) + unsigned int count = builder.encoded_nelts (); + for (unsigned int i = 0; i < count; i++) { rtx x = simplify_unary_operation (code, GET_MODE_INNER (mode), CONST_VECTOR_ELT (op, i), - GET_MODE_INNER (opmode));