From c0cc00c4f0e806d28ef6ed25671c75626817176e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Dec 2017 10:11:29 +0100 Subject: [PATCH] re PR rtl-optimization/82973 (ICE in output_constant_pool_2, at varasm.c:3896 on aarch64) PR rtl-optimization/82973 * emit-rtl.h (valid_for_const_vec_duplicate_p): Rename to ... (valid_for_const_vector_p): ... this. * emit-rtl.c (valid_for_const_vec_duplicate_p): Rename to ... (valid_for_const_vector_p): ... this. Adjust function comment. (gen_vec_duplicate): Adjust caller. * optabs.c (expand_vector_broadcast): Likewise. * simplify-rtx.c (simplify_const_unary_operation): Don't optimize into CONST_VECTOR if some element isn't simplified valid_for_const_vector_p constant. (simplify_const_binary_operation): Likewise. Use CONST_FIXED_P macro instead of GET_CODE == CONST_FIXED. (simplify_subreg): Use CONST_FIXED_P macro instead of GET_CODE == CONST_FIXED. * gfortran.dg/pr82973.f90: New test. From-SVN: r255938 --- gcc/ChangeLog | 15 +++++++++++++++ gcc/emit-rtl.c | 8 ++++---- gcc/emit-rtl.h | 2 +- gcc/optabs.c | 2 +- gcc/simplify-rtx.c | 10 +++++----- gcc/testsuite/ChangeLog | 3 +++ 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c526dd9c322..c411e4906db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,20 @@ 2017-12-21 Jakub Jelinek + PR rtl-optimization/82973 + * emit-rtl.h (valid_for_const_vec_duplicate_p): Rename to ... + (valid_for_const_vector_p): ... this. + * emit-rtl.c (valid_for_const_vec_duplicate_p): Rename to ... + (valid_for_const_vector_p): ... this. Adjust function comment. + (gen_vec_duplicate): Adjust caller. + * optabs.c (expand_vector_broadcast): Likewise. + * simplify-rtx.c (simplify_const_unary_operation): Don't optimize into + CONST_VECTOR if some element isn't simplified valid_for_const_vector_p + constant. + (simplify_const_binary_operation): Likewise. Use CONST_FIXED_P macro + instead of GET_CODE == CONST_FIXED. + (simplify_subreg): Use CONST_FIXED_P macro instead of + GET_CODE == CONST_FIXED. + PR target/83488 * config/i386/i386.c (ix86_target_string): Move -mavx512vbmi2 and -mshstk entries from isa_opts2 to isa_opts and -mhle, -mmovbe, diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 8ca192f5daf..53693bdfa74 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -5861,11 +5861,11 @@ init_emit (void) #endif } -/* Return true if X is a valid element for a duplicated vector constant - of the given mode. */ +/* Return true if X is a valid element for a CONST_VECTOR of the given + mode. */ bool -valid_for_const_vec_duplicate_p (machine_mode, rtx x) +valid_for_const_vector_p (machine_mode, rtx x) { return (CONST_SCALAR_INT_P (x) || CONST_DOUBLE_AS_FLOAT_P (x) @@ -5907,7 +5907,7 @@ gen_const_vec_duplicate (machine_mode mode, rtx elt) rtx gen_vec_duplicate (machine_mode mode, rtx x) { - if (valid_for_const_vec_duplicate_p (mode, x)) + if (valid_for_const_vector_p (mode, x)) return gen_const_vec_duplicate (mode, x); return gen_rtx_VEC_DUPLICATE (mode, x); } diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h index b219762d279..b8c2f8cbe2e 100644 --- a/gcc/emit-rtl.h +++ b/gcc/emit-rtl.h @@ -439,7 +439,7 @@ get_max_uid (void) return crtl->emit.x_cur_insn_uid; } -extern bool valid_for_const_vec_duplicate_p (machine_mode, rtx); +extern bool valid_for_const_vector_p (machine_mode, rtx); extern rtx gen_const_vec_duplicate (machine_mode, rtx); extern rtx gen_vec_duplicate (machine_mode, rtx); diff --git a/gcc/optabs.c b/gcc/optabs.c index 9fd0f823060..225e9558bc3 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -377,7 +377,7 @@ expand_vector_broadcast (machine_mode vmode, rtx op) gcc_checking_assert (VECTOR_MODE_P (vmode)); - if (valid_for_const_vec_duplicate_p (vmode, op)) + if (valid_for_const_vector_p (vmode, op)) return gen_const_vec_duplicate (vmode, op); icode = optab_handler (vec_duplicate_optab, vmode); diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 35c98fb883f..4f9796c7c84 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1768,7 +1768,7 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, rtx x = simplify_unary_operation (code, GET_MODE_INNER (mode), CONST_VECTOR_ELT (op, i), GET_MODE_INNER (opmode)); - if (!x) + if (!x || !valid_for_const_vector_p (mode, x)) return 0; RTVEC_ELT (v, i) = x; } @@ -4030,7 +4030,7 @@ simplify_const_binary_operation (enum rtx_code code, machine_mode mode, rtx x = simplify_binary_operation (code, GET_MODE_INNER (mode), CONST_VECTOR_ELT (op0, i), CONST_VECTOR_ELT (op1, i)); - if (!x) + if (!x || !valid_for_const_vector_p (mode, x)) return 0; RTVEC_ELT (v, i) = x; } @@ -4041,11 +4041,11 @@ simplify_const_binary_operation (enum rtx_code code, machine_mode mode, if (VECTOR_MODE_P (mode) && code == VEC_CONCAT && (CONST_SCALAR_INT_P (op0) - || GET_CODE (op0) == CONST_FIXED + || CONST_FIXED_P (op0) || CONST_DOUBLE_AS_FLOAT_P (op0)) && (CONST_SCALAR_INT_P (op1) || CONST_DOUBLE_AS_FLOAT_P (op1) - || GET_CODE (op1) == CONST_FIXED)) + || CONST_FIXED_P (op1))) { unsigned n_elts = GET_MODE_NUNITS (mode); rtvec v = rtvec_alloc (n_elts); @@ -6268,7 +6268,7 @@ simplify_subreg (machine_mode outermode, rtx op, if (CONST_SCALAR_INT_P (op) || CONST_DOUBLE_AS_FLOAT_P (op) - || GET_CODE (op) == CONST_FIXED + || CONST_FIXED_P (op) || GET_CODE (op) == CONST_VECTOR) { /* simplify_immed_subreg deconstructs OP into bytes and constructs diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 42d1746f68d..932ff87b7ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-12-21 Jakub Jelinek + PR rtl-optimization/82973 + * gfortran.dg/pr82973.f90: New test. + PR target/83488 * gcc.target/i386/pr83488.c: New test. -- 2.30.2