This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Fix PR target/17390, take 2


Hello!

This patch implements fix for target/17390. It is better to call a pass that
deletes instructions before register life data is calculated. This way, some
extra fstps are eliminated.

New optimization pass is now enabled with flag-expensive-optimizations, and its
compile time impact can be shown in time reports.

The testcases and further description can be found at:
http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01126.html
and
http://gcc.gnu.org/ml/gcc/2005-10/msg00657.html

The testcase from PR, compiled with (-O2 -ffast-math -march=i586 -mtune=i686
-fomit-frame-pointer) produces following asm:

to:

test:
        fldl    4(%esp)
        ftst
        fnstsw  %ax
        fstp    %st(0)
        sahf
        je      .L10
        jbe     .L5
        fld1
        ret
        .p2align 4,,7
.L10:
        fldz
        .p2align 4,,8
        ret
.L5:
        flds    .LC2
        .p2align 4,,4
        ret

FWIW, povray-3.6.1, compiled with patched gcc is now 2208 bytes smaller.

2005-10-21  Uros Bizjak  <uros@kss-loka.si>

	PR target/17390
	* Makefile.in (postreload.o): Depend on target.h.
	* postreload.c: Include target.h
	(gate_handle_machine_postreload, rest_of_handle_machine_postreload):
	New functions.
	(pass_machine_postreload): New pass descriptor.
	* tree-pass.h: Declare it.
	* passes.c (init_optimization_passes): Use it.

	* target.h (struct gcc_target): Add machine_dependent_postreload
	target hook.
	* target-def.h (TARGET_MACHINE_DEPENDENT_AFTER_RELOAD): New
	define, default to 0.  Add to TARGET_INITIALIZER.
	* timevar.def: Add TV_MACH_DEP_AFTER_RELOAD.

	* config/i386/i386.c (TARGET_MACHINE_DEPENDENT_AFTER_RELOAD):
	New define, defined to ix86_postreload.
	(ix86_postreload): New function.  Call ix86_cse_i387_compares for
	TARGET_80387 && !TARGET_CMOVE when !flag_trapping_math and
	flag_expensive_optimizations.

	* doc/tm.texi: Document TARGET_MACHINE_DEPENDENT_AFTER_RELOAD
	target hook.

testsuite:

	PR target/17390
	* gcc.target/i386/pr17390-1.c: New test.
	* gcc.target/i386/pr17390-2.c: New test.


Patch is tested on i686-pc-linux-gnu for c and c++. OK for 4.2?

Thanks,
Uros.

Attachment: pr17390-2.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]