From: Jan Hubicka <hubicka@horac.ta.jcu.cz>
To: egcs@cygnus.com
Subject: i387 control word...
Date: Fri, 16 Oct 1998 22:01:00 -0000 [thread overview]
Message-ID: <19981016214857.02176@horac.ta.jcu.cz> (raw)
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!
next reply other threads:[~1998-10-16 22:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-16 22:01 Jan Hubicka [this message]
1998-10-27 1:12 ` Jeffrey A Law
1998-11-04 15:31 ` Joern Rennecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19981016214857.02176@horac.ta.jcu.cz \
--to=hubicka@horac.ta.jcu.cz \
--cc=egcs@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).