[Bug target/17345] [3.5 Regression] internal compiler error: in optimize_mode_switching, at lcm.c:1225
uros at kss-loka dot si
gcc-bugzilla@gcc.gnu.org
Thu Sep 9 14:16:00 GMT 2004
------- Additional Comments From uros at kss-loka dot si 2004-09-09 14:16 -------
Jan,
thank you very much for looking into this bugreport! I admit, I didn't notice
this report, and I'm really sorry that even with a lot of testing, my patch
broke something. Your patch fixes this breakage, could you please commit it to CVS ?
Regarding my proposal, I would suggest to change mode handling from this scheme:
...
fldcw (new_mode)
fistp [or frndint]
fldcw (saved_mode)
...
fldcw (other_mode)
fistp [or frndint]
fldcw (saved_mode)
...
into something like this:
...
fldcw (new_mode)
fistp [or frndint]
...
fldcw (other_mode)
fistp [or frndint]
...
fldcw (saved_mode)
call [or __asm]
...
fldcw (other_mode)
fistp [or frndint[
...
fldcw (saved_mode)
return
Basically, fldcw would be emitted only when rounding mode changes. Also, with
this scheme fistp and frndint patterns could have dependency on FP_mode
register, which would hopefully address mode changing in for loops. As it is now:
...
loop {
fldcw (new_mode)
fistp
fldcw (saved_mode)
}
...
a better code could be generated:
...
fldcw (new_mode)
loop {
fistp
}
...
fldcw (saved_mode)
ret
I guess mode would need to be changed to saved before call instruction or __asm
and on return from function.
Another idea is to convert
(int) floor(double) into some kind of builtin_lfloor, etc on a tree level. This
builtin could then be expanded as fix_floor?f?i optab, and this could be
implemented with sse instructions as it is a case with fix_trunc?f?i optabs.
However, SSE has its own mode register and if handled the same way as i387 mode
register, another two stack slots would be needed to save old and new SSE
rounding mode value.
It is quite interesting, how many cases would this convertions catch. For
example, povray-3.50c:
grep floor *.cpp | grep int - | wc -l
39
grep floor *.cpp | grep long - | wc -l
7
grep ceil *.cpp | grep int - | wc -l
8
Uros.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17345
More information about the Gcc-bugs
mailing list