Bugzilla – Bug 219
[x86] X86 backend code generates -0.0 as +0.0
Last modified: 2004-02-02 13:35:14
You need to log in before you can comment on or make changes to this bug.
Testcase here: test/Programs/SingleSource/UnitTests/2004-02-02-NegativeZero.c http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040202/011067.html The problem is that the X86 backend emits the fldz instruction to produce a -0.0 value, but fldz pushes +0.0 on the stack! -Chris
This patch fixes the bug (do not trust == to compare FP values!): http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040202/011066.html While I was at it, I also added this patch: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040202/011074.html which causes the X86 code generator to generate the 'fchs' instruction to negate FP numbers efficiently. -Chris