From 868865f40f37e970ab1993d549e0bd9eb254ccc7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Apr 2018 10:39:50 +0200 Subject: [PATCH] re PR rtl-optimization/85342 (ICE: SIGSEGV in copyprop_hardreg_forward_1 (regcprop.c:995) with -O2 -mavx512vl) PR rtl-optimization/85342 * regcprop.c (copyprop_hardreg_forward_1): Remove replaced array, use a bool scalar var inside of the loop instead. Don't try to update recog_data.operand after failed apply_change_group. * gcc.target/i386/pr85342.c: New test. From-SVN: r259338 --- gcc/ChangeLog | 7 ++++++ gcc/regcprop.c | 24 +++++++------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr85342.c | 29 +++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr85342.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4d0882950a..469c6ff5649 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-12 Jakub Jelinek + + PR rtl-optimization/85342 + * regcprop.c (copyprop_hardreg_forward_1): Remove replaced array, use + a bool scalar var inside of the loop instead. Don't try to update + recog_data.operand after failed apply_change_group. + 2018-04-12 Tom de Vries PR target/85296 diff --git a/gcc/regcprop.c b/gcc/regcprop.c index e2a78a2b0e1..a664f76a8b0 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -751,7 +751,6 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) bool is_asm, any_replacements; rtx set; rtx link; - bool replaced[MAX_RECOG_OPERANDS]; bool changed = false; struct kill_set_value_data ksvd; @@ -934,7 +933,7 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) eldest live copy that's in an appropriate register class. */ for (i = 0; i < n_ops; i++) { - replaced[i] = false; + bool replaced = false; /* Don't scan match_operand here, since we've no reg class information to pass down. Any operands that we could @@ -951,26 +950,26 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) if (recog_data.operand_type[i] == OP_IN) { if (op_alt[i].is_address) - replaced[i] + replaced = replace_oldest_value_addr (recog_data.operand_loc[i], alternative_class (op_alt, i), VOIDmode, ADDR_SPACE_GENERIC, insn, vd); else if (REG_P (recog_data.operand[i])) - replaced[i] + replaced = replace_oldest_value_reg (recog_data.operand_loc[i], alternative_class (op_alt, i), insn, vd); else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); } else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); /* If we performed any replacement, update match_dups. */ - if (replaced[i]) + if (replaced) { int j; rtx new_rtx; @@ -989,13 +988,6 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) { if (! apply_change_group ()) { - for (i = 0; i < n_ops; i++) - if (replaced[i]) - { - rtx old = *recog_data.operand_loc[i]; - recog_data.operand[i] = old; - } - if (dump_file) fprintf (dump_file, "insn %u: reg replacements not verified\n", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 578e73b15e8..7d28a2b818d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-12 Jakub Jelinek + + PR rtl-optimization/85342 + * gcc.target/i386/pr85342.c: New test. + 2018-04-11 Jason Merrill * lib/asan-dg.exp (check_effective_target_fsanitize_address): False diff --git a/gcc/testsuite/gcc.target/i386/pr85342.c b/gcc/testsuite/gcc.target/i386/pr85342.c new file mode 100644 index 00000000000..941e9d45146 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85342.c @@ -0,0 +1,29 @@ +/* PR rtl-optimization/85342 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -mavx512vl" } */ + +typedef unsigned char U __attribute__((vector_size (64))); +typedef unsigned int V __attribute__((vector_size (64))); +typedef unsigned __int128 W __attribute__((vector_size (64))); +int i; +V g, h, z, k, l, m; +U j; + +W +bar (W o, W p) +{ + U q; + o |= (W){q[0]} >= o; + o += 1 < o; + j |= (U){} == j; + return i + (W)q + (W)g + (W)h + (W)z + o + (W)j + (W)k + (W)l + (W)m + p; +} + +W +foo (U u) +{ + U q; + W r = bar ((W)(U){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~0}, (W)q); + u += (U)bar ((W){~0}, r); + return (W)u; +} -- 2.30.2