This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: i387 control word...
- To: Jan Hubicka <hubicka at horac dot ta dot jcu dot cz>
- Subject: Re: i387 control word...
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 26 Oct 1998 19:46:43 -0700
- cc: egcs at cygnus dot com
- Reply-To: law at cygnus dot com
In message <19981016214857.02176@horac.ta.jcu.cz>you write:
> Hi
> I am thinking how to improve float->integer conversion at intel. Current
> situation is following: conversion is done by one instruction (fist),
> but you need to have set control word correctly. So pattern emits code
> to set cw first and asm looks like this:
>
> fnstcw 4(%esp) ; store control word
> movl 4(%esp),%edx ;
> movb $12,%dh ; set higher part to correct value
> movl %edx,(%esp) ;
> fldcw (%esp) ; load it
> subl $4,%esp
> fistpl (%esp) ; push the integer value
> popl %eax
> fldcw 4(%esp) ; return back...
>
> Problem is that this ceremony is done for EVERY truncation that makes code
> very bad.
> Easy solution is to assume, that CW is set correclty (it is in many cases)
> and make some option (like -mfast-fp-truncation) to just ignore this code.
> It should help to XaoS a lot. What do you think about it?
I think we'll be able to implement this as a lazy code motion problem too.
It ought to be fairly simple and work reliably.
Basically think about the problem at a higher level. What are you doing?
You're trying to eliminate redundant calculations.
So, the trick is to determine what operations set the value you want,
what operations kill the value you want, then run traditional redundancy
elimination algorithms.
We're going to need to solve a similar problem for the SH in the near
future, you'll probably be able to reuse much of that code.
jeff