This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] avoid xmm register in SSE float->int conversions
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Uros Bizjak <uros at kss-loka dot si>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Oct 2004 18:30:26 +0200
- Subject: Re: [PATCH] avoid xmm register in SSE float->int conversions
- References: <4173CE1D.8020408@kss-loka.si>
> Hello!
>
> For the DF->SI testcases like this:
>
> int test1(double a) {
> return sin(a);
> }
>
> current mainline gcc produces following code for -march=pentium4:
> ...
> fsin
> fstpl (%esp)
> movsd (%esp), %xmm0
> cvttsd2si %xmm0, %eax
> ...
> ret
>
> At least for pentium4 (and perhaps other !TARGET_K8 targets), xmm
> register could be avoided, as cvttsd2si can convert directly from memory
> to integer register. Attached patch introduces a couple of peephole2
> optimizers to get rid of extra movsd.
> Unfortunatelly, combine pass can't be used in this case, because all
> necessary moves are generated in greg pass _after_ combine.
To make the peepholes safe, you need to verify that xmm0 is dead after
it is stored to memoery again. However it is definitly better to teach
reload to not do this sillyness, but it might be quite dificult...
Honza