+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
}
}
- 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. */
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.
--- /dev/null
+// 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;
+}