x86 patch: SSE-based FP<=>int conversions, round 1

Stuart Hastings stuart@apple.com
Fri Dec 1 17:21:00 GMT 2006


GCC Darwin/x86 defaults to -mfpmath=sse.  GCC does a fine job with all  
the SSE conversion opcodes, but when SSE doesn't supply the operation  
we need (e.g. x86_32 DF -> unsigned_SI), GCC falls back to the x87.   
That works, but it's slow, as the value must be stored into memory  
before it can be loaded into the x87.

The attached patch adds several of these conversions using SSE.  It's  
not complete; for example, unsigned_SI -> SF is missing.  It's not  
truly optimal either, as  there are a few common cases where it really  
should fall back to the x87; for example, a conversion done for a  
return statement.  But the generated code is generally faster, often  
significantly.

A very similar patch is currently part of Apples GCC.

:ADDPATCH target/x86:


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gcc.fsf.cvt.diffs.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061201/1219f41d/attachment.txt>
-------------- next part --------------

2006-12-01  Stuart Hastings  <stuart@apple.com>

	* gcc/testsuite/gcc.target/i386/20061023-1.c: New.
	* gcc/config/i386/i386.md (fixuns_trunc<mode>si2, fixuns_truncdfhi2,
	fixuns_truncsfhi2, floatunssidf2, floatunsdidf3) New.
	(floatdidf2): Calll ix86_expand_convert_sign_DI2DF_sse.
	* gcc/config/i386/sse.md (movdi_to_sse): New.
	* gcc/config/i386/i386-protos.h (ix86_expand_convert_uns_DF2SI_sse,
	ix86_expand_convert_uns_SF2SI_sse, ix86_expand_convert_uns_DI2DF_sse,
	ix86_expand_convert_uns_SI2DF_sse,   
ix86_expand_convert_sign_DI2DF_sse): New.
	* gcc/config/i386/i386.c (ix86_expand_vector_move2, gen_2_4_rtvec,
	ix86_expand_convert_uns_DF2SI_sse, ix86_expand_convert_uns_SF2SI_sse,
	store_xmm_as_DF, ix86_expand_convert_uns_DI2DF_sse,
	ix86_expand_convert_uns_SI2DF_sse,  
ix86_expand_convert_sign_DI2DF_sse): New.

On Darwin/x86_32: bootstrapped, C/C++/ObjC/Obj-C++, DejaGnu (with  
default -mfpmath=387), DejaGnu -mfpmath=sse; no regressions.
On Linux/x86_64: bootstrapped, C/C++/ObjC, DejaGnu; no regressions.

O.K. for trunk?

stuart hastings
Apple Computer


More information about the Gcc-patches mailing list