re PR rtl-optimization/82913 (ICE: Segmentation fault in try_merge_compare)
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Nov 2017 23:58:51 +0000 (00:58 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Nov 2017 23:58:51 +0000 (00:58 +0100)
PR rtl-optimization/82913
* compare-elim.c (try_merge_compare): Punt if def_insn is not
single set.

* gcc.c-torture/compile/pr82913.c: New test.

From-SVN: r254614

gcc/ChangeLog
gcc/compare-elim.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr82913.c [new file with mode: 0644]

index 0c6f9489389783c267d64c303c24bd9d418bc3db..f2de9142e6ae84dc86ee940429f7885ee5a8da6c 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/82913
+       * compare-elim.c (try_merge_compare): Punt if def_insn is not
+       single set.
+
 2017-11-09  Jeff Law  <law@redhat.com>
 
        * vr-values.h: New file with vr_values class.
index 17d08842d159783093a01524f5163179de6e5f42..b34a07f833613a61cfa7bd6656ee63e60fe22583 100644 (file)
@@ -683,6 +683,8 @@ try_merge_compare (struct comparison *cmp)
 
   rtx_insn *def_insn = cmp->in_a_setter;
   rtx set = single_set (def_insn);
+  if (!set)
+    return false;
 
   if (!can_merge_compare_into_arith (cmp_insn, def_insn))
     return false;
index 17fa76628806635491efcec10bbed505547e0a8b..f50bee7ad5fa40f2ea11062a178eb3d5d277e123 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/82913
+       * gcc.c-torture/compile/pr82913.c: New test.
+
 2017-11-09  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/78619
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82913.c b/gcc/testsuite/gcc.c-torture/compile/pr82913.c
new file mode 100644 (file)
index 0000000..5cf5557
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/82913 */
+
+unsigned int a;
+unsigned long int b;
+
+int
+foo (void)
+{
+  ++a;
+  b = 0;
+}
+
+unsigned long int
+bar (int x)
+{
+  if (!foo () || !a)
+    {
+      int c = a != b;
+      if (c != x)
+        return a;
+    }
+  return 0;
+}