[PATCH, i386]: Optimization of the i386 and x86_64 compilers

Uros Bizjak ubizjak@gmail.com
Fri Mar 2 11:01:00 GMT 2007


Hello!

Attached patch implements the idea, proposed by Michael Meissner in PR
31019. The core of his idea is to substitute (1 << ix86_[tune|arch])
in x86_some_var & (1 << ix86_[tune|arch])) by a precalculated global
variable.

The results of this patch are quite suprising as the text size of cc1
on i686 host was lowered considerably:

size cc1
   text    data     bss     dec     hex filename
7632793   18876  574516 8226185  7d8589 cc1

size cc1-patched
   text    data     bss     dec     hex filename
6731749   18876  574516 7325141  6fc5d5 cc1-patched

Yes, for 901k.

This effect could be partially attributed to the way i386 handles
variable shifts. Unpached gcc uses code that also clobbers %ecx:

 8554612:	8b 0d 9c a1 81 08    	mov    0x881a19c,%ecx
 8554618:	a1 a4 4b 72 08       	mov    0x8724ba4,%eax
 855461d:	d3 f8                	sar    %cl,%eax
 855461f:	a8 01                	test   $0x1,%al

Patched gcc uses following code:

 8498762:	a1 a0 e1 73 08       	mov    0x873e1a0,%eax
 8498767:	85 05 04 8c 64 08    	test   %eax,0x8648c04


2007-03-02  Uros Bizjak  <ubizjak@gmail.com>
	    Michael Meissner  <michael.meissner@amd.com>

        * config/i386/i386.h (TUNEMASK): Redefine to use ix86_tune_mask.
	(ARCHMASK): Define.
	(TARGET_CMOVE): Use ARCHMASK.
	(TARGET_CMPXCHG): Ditto.
	(TARGET_CMPXCHG8B): Ditto.
	(TARGET_XADD): Ditto.
	(TARGET_BSWAP): Ditto.
	* config/i386/i386.c (ix86_tune_mask): New global variable.
	(ix86_arch_mask): Ditto.
	(override_options): Initialize ix86_tune_mask and
	ix86_arch_mask. Use ARCHMASK to clear MASK_NO_FANCY_MATH_387 in
	target_flags.

The patch was bootstrapped on i686-pc-linux-gnu, regression tested for
c, c++ and gfortran.

BTW: The patch also rearranges processors #defines into more logical sequence.

Uros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386-mask.diff
Type: application/octet-stream
Size: 4876 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070302/8dfa497a/attachment.obj>


More information about the Gcc-patches mailing list