This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
i387 control word...
- To: egcs at cygnus dot com
- Subject: i387 control word...
- From: Jan Hubicka <hubicka at horac dot ta dot jcu dot cz>
- Date: Fri, 16 Oct 1998 21:48:57 +0200
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?
For cases where this is neccesary I was thinking about different solution:
legitimize control word as global SImode reigster, make mov patterns for it
and then produce sequences like:
(set tmp_reg cw)
(set tmp_reg2 (and:SI tmp_reg 0xc00))
(set cw tmp_reg2)
(conversion)
(set cw tmp_reg)
and mark all fp oprations as they use cw. This should let optimizer be smart
about it. For example even in case loop does both calcualtion and truncation
it should just make two register containing the values and emit fldcw
instructions.. Also asm statements probably needs to be changed to implicitly
clobber control word.
Before making heoric attempts to implement this I want to ask if it
should work and if it is good way to go..... I am not sure how weell optimizer
handles such cases with hard reigsters (they don't seems to be optimized at
all) and so on... ase I want to ask if it is worthwhile...
Honza
--
------------------------------------------------------------------------------
Have you browsed my www pages? Look at:
http://www.paru.cas.cz/~hubicka
Koules-the game for Svgalib,X11 and OS/2, Xonix-the game for X11
czech documentation for linux index, original 2D computer art and
funny 100 years old photos and articles are there!