diff mbox

Update SSA_NAME manager to use two lists

Message ID 56182E51.7010908@redhat.com
State New
Headers show

Commit Message

Jeff Law Oct. 9, 2015, 9:14 p.m. UTC
On 09/30/2015 12:46 PM, Jakub Jelinek wrote:
> On Wed, Sep 30, 2015 at 11:44:38AM -0600, Jeff Law wrote:
>> +/* Move all SSA_NAMEs from FREE_SSA_NAMES_QUEUE to FREE_SSA_NAMES.
>> +
>> +   We do not, but should have a mode to verify the state of the SSA_NAMEs
>> +   lists.  In particular at this point every name must be in the IL,
>> +   on the free list or in the queue.  Anything else is an error.  */
>> +
>> +void
>> +flush_ssaname_freelist (void)
>> +{
>> +  while (!vec_safe_is_empty (FREE_SSANAMES_QUEUE (cfun)))
>> +    {
>> +      tree t = FREE_SSANAMES_QUEUE (cfun)->pop ();
>> +      vec_safe_push (FREE_SSANAMES (cfun), t);
>> +    }
>
> Isn't it faster to just do:
>    vec_safe_splice (FREE_SSANAMES (cfun), FREE_SSANAMES_QUEUE (cfun));
>    vec_safe_truncate (FREE_SSANAMES_QUEUE (cfun));
> or so?  I mean, rather than reallocating the vector perhaps many times
> grow it just once to the exact size, and memcpy there the data.
Fixed thusly.

Bootstrapped and regression tested on x86_64-linux-gnu.  Installed on 
the trunk.
jeff
commit 158044e96e95e4637a7c9519f864ec07d6a596de
Author: Jeff Law <law@redhat.com>
Date:   Fri Oct 9 15:14:16 2015 -0600

    Re: [PATCH] Update SSA_NAME manager to use two lists
    
    	* tree-ssanames.c (flush_ssaname_freelist): Use splice and truncate
    	rather than moving each name to the freelist individually.
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 69743c3..4b81033 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2015-10-09  Jeff Law  <law@redhat.com>
+
+	* tree-ssanames.c (flush_ssaname_freelist): Use splice and truncate
+	rather than moving each name to the freelist individually.
+
 2015-10-09  Steve Ellcey  <sellcey@imgtec.com>
 
 	* config.gcc (mips*-*-*): Add frame-header-opt.o to extra_objs.
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 91f4ed8..82fd4a1 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -127,11 +127,8 @@  ssanames_print_statistics (void)
 void
 flush_ssaname_freelist (void)
 {
-  while (!vec_safe_is_empty (FREE_SSANAMES_QUEUE (cfun)))
-    {
-      tree t = FREE_SSANAMES_QUEUE (cfun)->pop ();
-      vec_safe_push (FREE_SSANAMES (cfun), t);
-    }
+  vec_safe_splice (FREE_SSANAMES (cfun), FREE_SSANAMES_QUEUE (cfun));
+  vec_safe_truncate (FREE_SSANAMES_QUEUE (cfun), 0);
 }
 
 /* Return an SSA_NAME node for variable VAR defined in statement STMT