This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix tree-parloops (PR tree-optimization/58006)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 18 Aug 2013 17:14:49 +0200
- Subject: Re: [PATCH] Fix tree-parloops (PR tree-optimization/58006)
- References: <20130818142856 dot GM1814 at tucnak dot redhat dot com>
Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>take_address_of ICEs if an object has NULL DECL_NAME, the first hunk
>fixes
>that. But, there is no point creating extra runtime code for clobbers,
>like
>computing the address of the object, passing it from the serial code to
>the
>outlined parallelized routine and then just have a clobber there (not
>to
>mention that in 4.8 indirect clobbers aren't even allowed). So the
>patch
>also just kills clobbers from the parallelized regions.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>trunk/4.8?
>
Ok,
Thanks,
Richard.
>2013-08-18 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/58006
> * tree-parloops.c (take_address_of): Don't ICE if get_name
> returns NULL.
> (eliminate_local_variables_stmt): Remove clobber stmts.
>
> * g++.dg/opt/pr58006.C: New test.
>
>--- gcc/tree-parloops.c.jj 2013-05-06 17:08:48.000000000 +0200
>+++ gcc/tree-parloops.c 2013-08-16 16:35:54.454310095 +0200
>@@ -494,9 +494,12 @@ take_address_of (tree obj, tree type, ed
> if (gsi == NULL)
> return NULL;
> addr = TREE_OPERAND (*var_p, 0);
>- name = make_temp_ssa_name (TREE_TYPE (addr), NULL,
>- get_name (TREE_OPERAND
>- (TREE_OPERAND (*var_p, 0), 0)));
>+ const char *obj_name
>+ = get_name (TREE_OPERAND (TREE_OPERAND (*var_p, 0), 0));
>+ if (obj_name)
>+ name = make_temp_ssa_name (TREE_TYPE (addr), NULL, obj_name);
>+ else
>+ name = make_ssa_name (TREE_TYPE (addr), NULL);
> stmt = gimple_build_assign (name, addr);
> gsi_insert_on_edge_immediate (entry, stmt);
>
>@@ -694,6 +697,12 @@ eliminate_local_variables_stmt (edge ent
> dta.changed = true;
> }
> }
>+ else if (gimple_clobber_p (stmt))
>+ {
>+ stmt = gimple_build_nop ();
>+ gsi_replace (gsi, stmt, false);
>+ dta.changed = true;
>+ }
> else
> {
> dta.gsi = gsi;
>--- gcc/testsuite/g++.dg/opt/pr58006.C.jj 2013-08-16 16:55:49.398132255
>+0200
>+++ gcc/testsuite/g++.dg/opt/pr58006.C 2013-08-16 16:54:13.000000000
>+0200
>@@ -0,0 +1,22 @@
>+// PR tree-optimization/58006
>+// { dg-do compile }
>+// { dg-require-effective-target pthread }
>+// { dg-options "-Ofast -ftree-parallelize-loops=2" }
>+
>+extern "C" float sqrtf (float);
>+
>+struct S
>+{
>+ float i, j;
>+ float foo () const { return sqrtf (i * i + j * j); }
>+ S () : i (1), j (1) {}
>+};
>+
>+void
>+bar (int a, int b)
>+{
>+ int i;
>+ float f;
>+ for (i = a; i < b; i++)
>+ f = S ().foo ();
>+}
>
> Jakub