From bbc8d04f0e238cd5e86c240021b2c0aaf1b58d1b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 15 Dec 2018 00:17:03 +0100 Subject: [PATCH] re PR rtl-optimization/88478 (valgrind error in cselib_record_sets) PR rtl-optimization/88478 * cselib.c (cselib_record_sets): Move sets[i].src_elt tests after REG_P (dest) test. * g++.dg/opt/pr88478.C: New test. From-SVN: r267159 --- gcc/ChangeLog | 6 ++++++ gcc/cselib.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/pr88478.C | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr88478.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 492d9001e65..1ae1cc75633 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-12-15 Jakub Jelinek + + PR rtl-optimization/88478 + * cselib.c (cselib_record_sets): Move sets[i].src_elt tests + after REG_P (dest) test. + 2018-12-14 Martin Sebor PR tree-optimization/88372 diff --git a/gcc/cselib.c b/gcc/cselib.c index 4a68439455f..9d68e3c9723 100644 --- a/gcc/cselib.c +++ b/gcc/cselib.c @@ -2616,10 +2616,10 @@ cselib_record_sets (rtx_insn *insn) preserves the upper bits that di:SI=zero_extend(flags:CCNO<=0). */ scalar_int_mode mode; if (dest != orig - && sets[i].src_elt && cselib_record_sets_hook && REG_P (dest) && HARD_REGISTER_P (dest) + && sets[i].src_elt && is_a (GET_MODE (dest), &mode) && n_sets + n_strict_low_parts < MAX_SETS) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24d9ee661e1..8931a4c12ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-15 Jakub Jelinek + + PR rtl-optimization/88478 + * g++.dg/opt/pr88478.C: New test. + 2018-12-14 Martin Sebor PR tree-optimization/88372 diff --git a/gcc/testsuite/g++.dg/opt/pr88478.C b/gcc/testsuite/g++.dg/opt/pr88478.C new file mode 100644 index 00000000000..2081aad993e --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr88478.C @@ -0,0 +1,17 @@ +// PR rtl-optimization/88478 +// { dg-do compile } +// { dg-options "-O2" } + +struct A { + bool b; + int s; + template + A (T, U) {} +}; +enum F {} f; + +A +foo () +{ + return A (false, f); +} -- 2.30.2