This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix gimple slsr throwing call handling (PR tree-optimization/78777)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 12 Dec 2016 20:20:57 +0100
- Subject: [PATCH] Fix gimple slsr throwing call handling (PR tree-optimization/78777)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The strength reduction has code to emit stuff before or after the last insn
in a bb, but uses a wrong predicate to decide where to put it, is_ctrl_stmt
covers only a subset of statements that must end a bb.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2016-12-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/78777
* gimple-ssa-strength-reduction.c (create_add_on_incoming_edge,
insert_initializers): Use stmt_ends_bb_p instead of is_ctrl_stmt.
* g++.dg/torture/pr78777.C: New test.
--- gcc/gimple-ssa-strength-reduction.c.jj 2016-12-06 10:16:39.000000000 +0100
+++ gcc/gimple-ssa-strength-reduction.c 2016-12-12 16:50:24.729489536 +0100
@@ -2253,7 +2253,7 @@ create_add_on_incoming_edge (slsr_cand_t
insert_bb = single_succ_p (e->src) ? e->src : split_edge (e);
gsi = gsi_last_bb (insert_bb);
- if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi)))
+ if (!gsi_end_p (gsi) && stmt_ends_bb_p (gsi_stmt (gsi)))
{
gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);
if (cast_stmt)
@@ -3243,7 +3243,7 @@ insert_initializers (slsr_cand_t c)
gimple *basis_stmt = lookup_cand (c->basis)->cand_stmt;
location_t loc = gimple_location (basis_stmt);
- if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi)))
+ if (!gsi_end_p (gsi) && stmt_ends_bb_p (gsi_stmt (gsi)))
{
if (cast_stmt)
{
--- gcc/testsuite/g++.dg/torture/pr78777.C.jj 2016-12-12 17:21:00.864314692 +0100
+++ gcc/testsuite/g++.dg/torture/pr78777.C 2016-12-12 17:20:35.000000000 +0100
@@ -0,0 +1,29 @@
+// PR tree-optimization/78777
+
+void bar (char);
+struct C { char b; };
+struct H { char d[5]; int e; C *f[4]; int g[10]; };
+void baz (C *, unsigned char *, int);
+unsigned char j[10];
+
+void
+foo (H *o, int p, unsigned char *q, int r, char n, H *b)
+{
+ for (int m = 0; m < o->e; m++)
+ {
+ if (o->f[m] || o->g[m])
+ continue;
+ try
+ {
+ baz (o->f[m], j, 5);
+ if (p)
+ baz (o->f[m], q, r);
+ }
+ catch (int)
+ {
+ C a = *o->f[m];
+ if (b)
+ bar (n & a.b);
+ }
+ }
+}
Jakub