re PR rtl-optimization/88478 (valgrind error in cselib_record_sets)
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Dec 2018 23:17:03 +0000 (00:17 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 14 Dec 2018 23:17:03 +0000 (00:17 +0100)
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
gcc/cselib.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr88478.C [new file with mode: 0644]

index 492d9001e656dc86a97382714c20e5b5afe415f8..1ae1cc756338d1df201c6d0e7df0cea82a41b8f5 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <msebor@redhat.com>
 
        PR tree-optimization/88372
index 4a68439455fde0651bad43f1a6efdbe099c5ddf2..9d68e3c97236279f11d1c604f5f391a3f23874af 100644 (file)
@@ -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 <scalar_int_mode> (GET_MODE (dest), &mode)
          && n_sets + n_strict_low_parts < MAX_SETS)
        {
index 24d9ee661e11ae1cd24b8d4b592f715f71237319..8931a4c12ec058a3ff77514323a6cb6ebb170368 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/88478
+       * g++.dg/opt/pr88478.C: New test.
+
 2018-12-14  Martin Sebor  <msebor@redhat.com>
 
        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 (file)
index 0000000..2081aad
--- /dev/null
@@ -0,0 +1,17 @@
+// PR rtl-optimization/88478
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A {
+  bool b;
+  int s;
+  template <typename T, typename U>
+  A (T, U) {}
+};
+enum F {} f;
+
+A
+foo ()
+{
+  return A (false, f);
+}