Message ID | or1unxfnym.fsf@livre.localdomain |
---|---|
State | New |
Headers | show |
On Apr 9, 2012, Alexandre Oliva <aoliva@redhat.com> wrote: > On Jun 4, 2011, Alexandre Oliva <aoliva@redhat.com> wrote: >> On Oct 13, 2009, Alexandre Oliva <aoliva@redhat.com> wrote: >>> On Jun 1, 2009, Alexandre Oliva <aoliva@redhat.com> wrote: >>>> A long time ago, when variable tracking at assignments was just a >>>> distant dream, we ran into one of the first contentious points, which >>>> had to do with coalescing SSA names on copyrename. >>>> On the one hand, coalescing unrelated SSA names made for better code (at >>>> least in theory) but poorer debug information; on the other hand, >>>> refraining from coalescing them exploded compile-time memory use. >>>> We currently implement a trade-off by which variables inlined from other >>>> functions can be coalesced, so as to save compile-time memory, reduce >>>> abstraction penalties and retain debug information for out-of-line >>>> functions. >>>> The patch below (ping) implements two other possibilities: refraining >>>> from coalescing even inlined SSA names, which might enable better debug >>>> information to be generated, and enabling coalescing of all related >>>> variables, for better code at the expense of debug information. >>>> VTA doesn't really care which of the 3 possibilities is used, it works >>>> equally well with all of them. >>> On Jun 1, 2009, Alexandre Oliva <aoliva@redhat.com> also wrote: >>>> And the patch below changes the default so that we can optimize more. >>> This patch combines the two patches described above, now that VTA is >>> enabled by default. >> This is an updated version of the patch, adjusting the testcases that >> didn't expect this kind of variable coalescing. > Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok? > for gcc/ChangeLog > from Alexandre Oliva <aoliva@redhat.com> > * common.opt (ftree-coalesce-inlined-vars): New. > (ftree-coalesce-vars): New. > * doc/invoke.texi: Document them. > * tree-ssa-copyrename.c (copy_rename_partition_coalesce): > Implement them. > for gcc/testsuite/ChangeLog > from Alexandre Oliva <aoliva@redhat.com> > * g++.dg/tree-ssa/ivopts-2.C: Adjust for coalescing. > * gcc.dg/tree-ssa/forwprop-11.c: Likewise. > * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise. > Ping? (Updated with improved docs; should the options be renamed to > -ftree-copyrename-* to match the option that covers the entire pass?) Ping? http://gcc.gnu.org/ml/gcc-patches/2012-04/msg00412.html
On Wed, Jun 13, 2012 at 10:09 AM, Alexandre Oliva <aoliva@redhat.com> wrote: > On Apr 9, 2012, Alexandre Oliva <aoliva@redhat.com> wrote: > >> On Jun 4, 2011, Alexandre Oliva <aoliva@redhat.com> wrote: > >>> On Oct 13, 2009, Alexandre Oliva <aoliva@redhat.com> wrote: >>>> On Jun 1, 2009, Alexandre Oliva <aoliva@redhat.com> wrote: >>>>> A long time ago, when variable tracking at assignments was just a >>>>> distant dream, we ran into one of the first contentious points, which >>>>> had to do with coalescing SSA names on copyrename. > >>>>> On the one hand, coalescing unrelated SSA names made for better code (at >>>>> least in theory) but poorer debug information; on the other hand, >>>>> refraining from coalescing them exploded compile-time memory use. > >>>>> We currently implement a trade-off by which variables inlined from other >>>>> functions can be coalesced, so as to save compile-time memory, reduce >>>>> abstraction penalties and retain debug information for out-of-line >>>>> functions. > >>>>> The patch below (ping) implements two other possibilities: refraining >>>>> from coalescing even inlined SSA names, which might enable better debug >>>>> information to be generated, and enabling coalescing of all related >>>>> variables, for better code at the expense of debug information. > >>>>> VTA doesn't really care which of the 3 possibilities is used, it works >>>>> equally well with all of them. > >>>> On Jun 1, 2009, Alexandre Oliva <aoliva@redhat.com> also wrote: > >>>>> And the patch below changes the default so that we can optimize more. > >>>> This patch combines the two patches described above, now that VTA is >>>> enabled by default. > >>> This is an updated version of the patch, adjusting the testcases that >>> didn't expect this kind of variable coalescing. > >> Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok? Ok. Thanks, Richard. > >> for gcc/ChangeLog >> from Alexandre Oliva <aoliva@redhat.com> > >> * common.opt (ftree-coalesce-inlined-vars): New. >> (ftree-coalesce-vars): New. >> * doc/invoke.texi: Document them. >> * tree-ssa-copyrename.c (copy_rename_partition_coalesce): >> Implement them. > >> for gcc/testsuite/ChangeLog >> from Alexandre Oliva <aoliva@redhat.com> > >> * g++.dg/tree-ssa/ivopts-2.C: Adjust for coalescing. >> * gcc.dg/tree-ssa/forwprop-11.c: Likewise. >> * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise. > >> Ping? (Updated with improved docs; should the options be renamed to >> -ftree-copyrename-* to match the option that covers the entire pass?) > > Ping? http://gcc.gnu.org/ml/gcc-patches/2012-04/msg00412.html > > -- > Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ > You must be the change you wish to see in the world. -- Gandhi > Be Free! -- http://FSFLA.org/ FSF Latin America board member > Free Software Evangelist Red Hat Brazil Compiler Engineer
for gcc/ChangeLog from Alexandre Oliva <aoliva@redhat.com> * common.opt (ftree-coalesce-inlined-vars): New. (ftree-coalesce-vars): New. * doc/invoke.texi: Document them. * tree-ssa-copyrename.c (copy_rename_partition_coalesce): Implement them. for gcc/testsuite/ChangeLog from Alexandre Oliva <aoliva@redhat.com> * g++.dg/tree-ssa/ivopts-2.C: Adjust for coalescing. * gcc.dg/tree-ssa/forwprop-11.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise. Index: gcc/common.opt =================================================================== --- gcc/common.opt.orig 2012-04-08 01:44:00.731983395 -0300 +++ gcc/common.opt 2012-04-08 01:50:38.387224820 -0300 @@ -1926,6 +1926,14 @@ ftree-ch Common Report Var(flag_tree_ch) Optimization Enable loop header copying on trees +ftree-coalesce-inlined-vars +Common Report Var(flag_ssa_coalesce_vars,1) Init(2) RejectNegative Optimization +Enable coalescing of copy-related user variables that are inlined + +ftree-coalesce-vars +Common Report Var(flag_ssa_coalesce_vars,2) Optimization +Enable coalescing of all copy-related user variables + ftree-copyrename Common Report Var(flag_tree_copyrename) Optimization Replace SSA temporaries with better names in copies Index: gcc/tree-ssa-copyrename.c =================================================================== --- gcc/tree-ssa-copyrename.c.orig 2012-04-08 01:44:00.858981874 -0300 +++ gcc/tree-ssa-copyrename.c 2012-04-08 01:50:38.474223779 -0300 @@ -194,20 +194,21 @@ copy_rename_partition_coalesce (var_map ign1 = TREE_CODE (root1) == VAR_DECL && DECL_IGNORED_P (root1); ign2 = TREE_CODE (root2) == VAR_DECL && DECL_IGNORED_P (root2); - /* Never attempt to coalesce 2 user variables unless one is an inline - variable. */ + /* Refrain from coalescing user variables, if requested. */ if (!ign1 && !ign2) { - if (DECL_FROM_INLINE (root2)) - ign2 = true; - else if (DECL_FROM_INLINE (root1)) + if (flag_ssa_coalesce_vars && DECL_FROM_INLINE (root2)) + ign2 = true; + else if (flag_ssa_coalesce_vars && DECL_FROM_INLINE (root1)) ign1 = true; - else + else if (flag_ssa_coalesce_vars != 2) { if (debug) fprintf (debug, " : 2 different USER vars. No coalesce.\n"); return false; } + else + ign2 = true; } /* If both values have default defs, we can't coalesce. If only one has a Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi.orig 2012-04-08 01:44:00.989980308 -0300 +++ gcc/doc/invoke.texi 2012-04-08 01:50:38.846219327 -0300 @@ -404,7 +404,8 @@ Objective-C and Objective-C++ Dialects}. -fsplit-ivs-in-unroller -fsplit-wide-types -fstack-protector @gol -fstack-protector-all -fstrict-aliasing -fstrict-overflow @gol -fthread-jumps -ftracer -ftree-bit-ccp @gol --ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop @gol +-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol +-ftree-coalesce-inline-vars -ftree-coalesce-vars -ftree-copy-prop @gol -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol -ftree-forwprop -ftree-fre -ftree-loop-if-convert @gol -ftree-loop-if-convert-stores -ftree-loop-im @gol @@ -7434,6 +7435,24 @@ temporaries to other variables at copy l variable names which more closely resemble the original variables. This flag is enabled by default at @option{-O} and higher. +@item -ftree-coalesce-inlined-vars +Tell the copyrename pass (see @option{-ftree-copyrename}) to attempt to +combine small user-defined variables too, but only if they were inlined +from other functions. It is a more limited form of +@option{-ftree-coalesce-vars}. This may harm debug information of such +inlined variables, but it will keep variables of the inlined-into +function apart from each other, such that they are more likely to +contain the expected values in a debugging session. This was the +default in GCC versions older than 4.7. + +@item -ftree-coalesce-vars +Tell the copyrename pass (see @option{-ftree-copyrename}) to attempt to +combine small user-defined variables too, instead of just compiler +temporaries. This may severely limit the ability to debug an optimized +program compiled with @option{-fno-var-tracking-assignments}. In the +negated form, this flag prevents SSA coalescing of user variables, +including inlined ones. This option is enabled by default. + @item -ftree-ter @opindex ftree-ter Perform temporary expression replacement during the SSA->normal phase. Single Index: gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C =================================================================== --- gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C.orig 2012-04-08 01:44:01.157978296 -0300 +++ gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C 2012-04-08 01:50:38.868219064 -0300 @@ -7,5 +7,5 @@ void test (int *b, int *e, int stride) *p = 1; } -/* { dg-final { scan-tree-dump-times "PHI <p" 1 "ivopts"} } */ +/* { dg-final { scan-tree-dump-times "PHI <\[pb\]" 1 "ivopts"} } */ /* { dg-final { cleanup-tree-dump "ivopts" } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c.orig 2012-04-08 01:44:01.249977196 -0300 +++ gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c 2012-04-08 01:50:38.884218873 -0300 @@ -16,5 +16,5 @@ int g(int *p, int n) return q[-1]; } -/* { dg-final { scan-tree-dump-times "= MEM\\\[\\\(int \\\*\\\)a_.. \\\+ 4B\\\];" 2 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "= MEM\\\[\\\(int \\\*\\\)\[ap\]_.. \\\+ 4B\\\];" 2 "forwprop1" } } */ /* { dg-final { cleanup-tree-dump "forwprop1" } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c.orig 2012-04-08 01:44:01.429975039 -0300 +++ gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c 2012-04-08 01:50:38.896218729 -0300 @@ -11,5 +11,5 @@ int f(int *a) return *c + t; } -/* { dg-final { scan-tree-dump "Replaced \\\*c_\[^\n\].*with t_" "fre1" } } */ +/* { dg-final { scan-tree-dump "Replaced \\\*\[ac\]_\[^\n\].*with t_" "fre1" } } */ /* { dg-final { cleanup-tree-dump "fre1" } } */