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] Improve Powerpc (double)(int) rounding


While I wasn't able to get to my latest ideas in speeding up floating point
rounding on VSX, I've had this patch sometime in my sandbox.  I just retested
it and it bootstraps and causes no regressions in make check.  Is it ok to
apply?

For (double)(int)x, the current compiler does:

   1) convert x to 32-bit in a FPR
   2) store value on stack from FPR
   3) load value into GPR
   4) store value from GPR into stack
   5) load value into FPR
   6) Do int to double conversion

This patch combines the two conversions, and uses a single memory slot:

   1) convert x to 32-bit in a FPR
   2) store value on stack from FPR
   3) load value into FPR
   4) Do int to double conversion

For GCC 4.7, I want to do the conversion by doing a FRIZ (round to integer),
and then do min of (double)INT_MIN, and max of (double)INT_MAX, as a separate
gimple pass, rather than doing the stores.

[gcc]
2010-10-22  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000.md (floatsi<mode>2_lfiwax): Rewrite so
	split occurs before reload, and we allocate memory at the time of
	the split, not during expansion.  Add attributes.
	(floatsi<mode>2_lfiwax_mem): Ditto.
	(floatunssi<mode>2_lfiwzx): Ditto.
	(floatunssi<mode>2_lfiwzx_mem): Ditto.
	(floatsidf2): Ditto.
	(floatunssisf2): Ditto.
	(floatunssidf2): Ditto.
	(fix_trunc<mode>si2): Ditto.
	(fix_trunc<mode>si2_stfiwx): Ditto.
	(fix_trunc<mode>si2_internal): Ditto.
	(fix_trunc<mode>si2): Ditto.
	(fix_trunc<mode>di2): Ditto.
	(fixuns_trunc<mode>si2_stfiwx): Ditto.
	(floatsisf2): Ditto.
	(floatdidf2_mem): Ditto.
	(floatunsdidf2_mem): Ditto.
	(floatunsdidf2): Ditto.
	(floatdisf2_internal1): Ditto.
	(floatdisf2_mem): Ditto.
	(floatunsdisf2_mem): Ditto.
	(floatsi<mode>2_lfiwax_mem2): Delete.
	(floatunssi<mode>2_lfiwzx_mem2): Ditto.
	(fix_trunc<mode>si2_mem): Ditto.
	(fixuns_trunc<mode>si2_mem): Ditto.
	(round32<mode>2_fprs): New combiner insn to combine (double)(int)
	type operations to reduce copying the values to multiple memory
	slots.
	(roundu32<mode>2_fprs): Ditto.

	* config/rs6000/rs6000.c (rs6000_address_for_fpconvert): Handle
	PRE_INC, PRE_DEC, PRE_MODIFY.
	(rs6000_expand_convert_si_to_sfdf): Delete, no longer used.

[gcc/testsuite]
2010-10-22  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* gcc.target/powerpc/ppc-round.c: New file, test (double)(int)
	optimization.

	* gcc.target/powerpc/ppc-fpconv-2.c: Update # times lfiwax is
	expected.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com

Attachment: gcc-power7.patch176b
Description: Text document


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