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]

Re: [PATCH] avoid xmm register in SSE float->int conversions


> 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


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