[patch] cse.c: Use xmalloc instead of xrealloc in init_cse_reg_info.
Kazu Hirata
kazu@cs.umass.edu
Sun Feb 20 17:50:00 GMT 2005
Hi,
Attached is a patch to replace xrealloc with xmalloc as there is not
much point preserving the contents of cse_reg_info_table.
Here is time in *microseconds* spent in init_cse_reg_info while
compiling fold-const.i (measured using the rdtsc instruction on my
x86).
original patched patched*
131 116 640
patched* is a version of cse.c where I allocate and free the entire
cse_reg_info_table for every invocation of cse_main, which turns out
to be more expensive but by only 0.5ms.
The speed-up is very tiny, but I'd like to clean up my own mess, use
of xrealloc.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2005-02-19 Kazu Hirata <kazu@cs.umass.edu>
* cse.c (init_cse_reg_info): Use xmalloc instead of xrealloc.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.342
diff -c -d -p -r1.342 cse.c
*** cse.c 10 Feb 2005 20:13:19 -0000 1.342
--- cse.c 16 Feb 2005 17:02:49 -0000
*************** init_cse_reg_info (unsigned int nregs)
*** 864,873 ****
}
/* Reallocate the table with NEW_SIZE entries. */
! cse_reg_info_table = xrealloc (cse_reg_info_table,
! (sizeof (struct cse_reg_info)
! * new_size));
cse_reg_info_table_size = new_size;
}
/* Do we have all of the first NREGS entries initialized? */
--- 864,875 ----
}
/* Reallocate the table with NEW_SIZE entries. */
! if (cse_reg_info_table)
! free (cse_reg_info_table);
! cse_reg_info_table = xmalloc (sizeof (struct cse_reg_info)
! * new_size);
cse_reg_info_table_size = new_size;
+ cse_reg_info_table_first_uninitialized = 0;
}
/* Do we have all of the first NREGS entries initialized? */
More information about the Gcc-patches
mailing list