From 73cca0cc94027192b06c8b7897fe5fbe20de566e Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Wed, 30 Jan 2013 17:20:39 +0000 Subject: [PATCH] re PR rtl-optimization/56144 (ICE in get_reload_reg, at lra-constraints.c:421) 2013-01-30 Vladimir Makarov PR rtl-optimization/56144 * lra-constraints.c (get_reload_reg): Don't reuse reload pseudo for values with side effects. 2013-01-30 Vladimir Makarov PR rtl-optimization/56144 * gcc.dg/pr56144.c: New. From-SVN: r195582 --- gcc/ChangeLog | 6 ++++++ gcc/lra-constraints.c | 38 ++++++++++++++++++---------------- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/gcc.dg/pr56144.c | 35 +++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr56144.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 44535edfb00..0eb5f7c3e3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-01-30 Vladimir Makarov + + PR rtl-optimization/56144 + * lra-constraints.c (get_reload_reg): Don't reuse reload pseudo + for values with side effects. + 2013-01-30 Richard Biener * sparseset.h (sparseset_bit_p): Use gcc_checking_assert. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 03728b78f42..cc288540fc2 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -414,24 +414,26 @@ get_reload_reg (enum op_type type, enum machine_mode mode, rtx original, = lra_create_new_reg_with_unique_value (mode, original, rclass, title); return true; } - for (i = 0; i < curr_insn_input_reloads_num; i++) - if (rtx_equal_p (curr_insn_input_reloads[i].input, original) - && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class)) - { - lra_assert (! side_effects_p (original)); - *result_reg = curr_insn_input_reloads[i].reg; - regno = REGNO (*result_reg); - if (lra_dump_file != NULL) - { - fprintf (lra_dump_file, " Reuse r%d for reload ", regno); - dump_value_slim (lra_dump_file, original, 1); - } - if (new_class != lra_get_allocno_class (regno)) - change_class (regno, new_class, ", change", false); - if (lra_dump_file != NULL) - fprintf (lra_dump_file, "\n"); - return false; - } + /* Prevent reuse value of expression with side effects, + e.g. volatile memory. */ + if (! side_effects_p (original)) + for (i = 0; i < curr_insn_input_reloads_num; i++) + if (rtx_equal_p (curr_insn_input_reloads[i].input, original) + && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class)) + { + *result_reg = curr_insn_input_reloads[i].reg; + regno = REGNO (*result_reg); + if (lra_dump_file != NULL) + { + fprintf (lra_dump_file, " Reuse r%d for reload ", regno); + dump_value_slim (lra_dump_file, original, 1); + } + if (new_class != lra_get_allocno_class (regno)) + change_class (regno, new_class, ", change", false); + if (lra_dump_file != NULL) + fprintf (lra_dump_file, "\n"); + return false; + } *result_reg = lra_create_new_reg (mode, original, rclass, title); lra_assert (curr_insn_input_reloads_num < LRA_MAX_INSN_RELOADS); curr_insn_input_reloads[curr_insn_input_reloads_num].input = original; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c6a0df929a..17c91ee8628 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,15 @@ +2013-01-30 Vladimir Makarov + + PR rtl-optimization/56144 + * gcc.dg/pr56144.c: New. + 2013-01-30 David Edelsohn * g++.dg/cpp0x/constexpr-53094-2.C: Ignore non-standard ABI message. * g++.dg/cpp0x/constexpr-53094-3.C: Same. * g++.dg/cpp0x/constexpr-55573.C: Same - + 2013-01-30 Georg-Johann Lay PR tree-optimization/56064 diff --git a/gcc/testsuite/gcc.dg/pr56144.c b/gcc/testsuite/gcc.dg/pr56144.c new file mode 100644 index 00000000000..4b98225900f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr56144.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/56144 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int a; +union U0 { volatile unsigned f2, f4; }; +volatile int b; +static union U0 c; +volatile unsigned d, f; +volatile int e, g, h, i, j, k, l, m, n, o, p; +int +main () +{ + a = b; + a += c.f2; + a += c.f4; + unsigned q = h; + a += q; + q = g; + a += q; + a += f; + q = e; + a += q; + a += d; + a += 2L; + a += j; + a += i; + a += k; + a += p; + a += o; + a += n; + a += m; + a += l; + return 0; +} -- 2.30.2