]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/80297 (Compiler time crash: type mismatch in binary expression)
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Apr 2017 19:14:47 +0000 (21:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 4 Apr 2017 19:14:47 +0000 (21:14 +0200)
PR c++/80297
* genmatch.c (capture::gen_transform): For GENERIC unshare_expr
captures used multiple times, except for the last use.
* generic-match-head.c: Include gimplify.h.

* g++.dg/torture/pr80297.C: New test.

Co-Authored-By: Richard Biener <rguenther@suse.de>
From-SVN: r246693

gcc/ChangeLog
gcc/generic-match-head.c
gcc/genmatch.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr80297.C [new file with mode: 0644]

index d537ac5099a6366f372f6ed502b36a7379914668..ac9ab8ad96014dde23fc7460e8fb099841f1f4a9 100644 (file)
@@ -1,3 +1,11 @@
+2017-04-04  Jakub Jelinek  <jakub@redhat.com>
+           Richard Biener  <rguenther@suse.de>
+
+       PR c++/80297
+       * genmatch.c (capture::gen_transform): For GENERIC unshare_expr
+       captures used multiple times, except for the last use.
+       * generic-match-head.c: Include gimplify.h.
+
 2017-04-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/79390
index 1392d029f3e3f843ce9cd50d00a7d75863916de1..04e0854fd75b28e01331bd0da26f2c1973d64104 100644 (file)
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "dumpfile.h"
 #include "case-cfn-macros.h"
+#include "gimplify.h"
 
 
 /* Routine to determine if the types T1 and T2 are effectively
index 93d5b21d0bef71aa59feb9d87a8ae21c95b7a14c..5621aa05b59d2f1dd19b66c466bf3c3c124d67c7 100644 (file)
@@ -2525,7 +2525,18 @@ capture::gen_transform (FILE *f, int indent, const char *dest, bool gimple,
        }
     }
 
-  fprintf_indent (f, indent, "%s = captures[%u];\n", dest, where);
+  /* If in GENERIC some capture is used multiple times, unshare it except
+     when emitting the last use.  */
+  if (!gimple
+      && cinfo->info.exists ()
+      && cinfo->info[cinfo->info[where].same_as].result_use_count > 1)
+    {
+      fprintf_indent (f, indent, "%s = unshare_expr (captures[%u]);\n",
+                     dest, where);
+      cinfo->info[cinfo->info[where].same_as].result_use_count--;
+    }
+  else
+    fprintf_indent (f, indent, "%s = captures[%u];\n", dest, where);
 
   /* ???  Stupid tcc_comparison GENERIC trees in COND_EXPRs.  Deal
      with substituting a capture of that.  */
index 6d1ed2227b750c6774731e6aabfe7365d6bd0f2b..bdb1c01c6e6459ca7b8c61b20f6ccd79911940cc 100644 (file)
@@ -1,5 +1,8 @@
 2017-04-04  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/80297
+       * g++.dg/torture/pr80297.C: New test.
+
        PR tree-optimization/79390
        * gcc.target/i386/pr79390.c: New test.
        * gcc.dg/ifcvt-4.c: Use -mtune-ctrl=^one_if_conv_insn for i?86/x86_64.
diff --git a/gcc/testsuite/g++.dg/torture/pr80297.C b/gcc/testsuite/g++.dg/torture/pr80297.C
new file mode 100644 (file)
index 0000000..3b246e4
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/80297
+// { dg-do compile }
+
+extern const unsigned long int b;
+extern const long long int c;
+
+int
+foo ()
+{
+  int a = 809 >> -(b & !c) + b - (long long)(b & !c);
+  return a;
+}