This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
i386 FP comparsion bug (and sollution)
- To: egcs at cygnus dot com
- Subject: i386 FP comparsion bug (and sollution)
- From: Jan Hubicka <hubicka at atrey dot karlin dot mff dot cuni dot cz>
- Date: Mon, 26 Oct 1998 09:05:05 +0100
Hi
I think I've tracked down quite important bug in condition code in i386.c/md.
The problem happends often when -mno-ieee-fp is set (that should be purpose
why it is considered as buggy) but happends rarely in normal comparsions too.
The condition code ocasinally sets the CC_REVERSED and TEST_AX (in -mno-ieee-fp
case) flags in cc_status variable. This usually works well.
Problem is, that reg-stack pass should emit some swap/mov?f patterns between
codition and jump. Handling of cc_status variable is then controlled in
NOTICE_UPDATE macro, that do approx following:
it is able to recognize condition and set the "default" flags for condition
it is able to recognize move and keep the flags and it is unable to recognize
swap and then clears the flags.
In case some instructions are between, it keeps flags correctly in case of
move patterns and sets them incorrectly in case of swap pattern. This is
easilly fixed in my tree by handling swap as move.
Problem is that before jump instruction, the NOTICE_UPDATE is called once
again for the condition insn (don't know why). It does recognize it and
sets the incorrect default values. Incorrect jump insn is emited then.
It is tricky to construct testcase, so I don't have any working with
latest snapshots without my patches, but hope description is clear.
My attempt to fix that is following: I've removed setting code from NOTICE_UPDATE
for FP conditions and added it to every pattern handling the conditions, so
flags are set correctly after pattern is output. NOTOCE_UPDATE is also modified
to recognize swap patterns, so it keeps unchanged until jump instruction is
output and everything seems to work well.
The fix is IMO rather unclean and I am not 100% sure what I am doing, so I am
asking here for some suggestions. Otherwise I will send the fix together with
some part of my patch to egcs-patches soon.
Honza
--
OK. Lets make a signature file.
+-------------------------------------------------------------------------+
| Jan Hubicka (Jan Hubi\v{c}ka in TeX) hubicka@freesoft.cz |
| Czech free software foundation: http://www.freesoft.cz |
|AA project - the new way for computer graphics - http://www.ta.jcu.cz/aa |
| homepage: http://www.paru.cas.cz/~hubicka/, games koules, Xonix, fast |
| fractal zoomer XaoS, index of Czech GNU/Linux/UN*X documentation etc. |
+-------------------------------------------------------------------------+