Commit e98e6340 by Segher Boessenkool Committed by Segher Boessenkool

Fix comparison of decimal float zeroes (PR80692)

Decimal float negative zero should compare equal to positive zero.
Decimal float zeroes are encoded as value class "normal" (in real.c);
they need to be handled specially, but in this one case that does not
yet happen.  This fixes it.


	PR middle-end/80692
	* real.c (do_compare): Give decimal_do_compare preference over
	comparing just the signs.

gcc/testsuite/
	PR middle-end/80692
	* gcc.c-torture/execute/pr80692.c: New testcase.

From-SVN: r248174
parent 78eca309
2017-05-17 Segher Boessenkool <segher@kernel.crashing.org>
PR middle-end/80692
* real.c (do_compare): Give decimal_do_compare preference over
comparing just the signs.
2017-05-17 Uros Bizjak <ubizjak@gmail.com>
* doc/md.texi (Canonicalization of Instructions): Describe the
......
......@@ -960,12 +960,12 @@ do_compare (const REAL_VALUE_TYPE *a, const REAL_VALUE_TYPE *b,
gcc_unreachable ();
}
if (a->sign != b->sign)
return -a->sign - -b->sign;
if (a->decimal || b->decimal)
return decimal_do_compare (a, b, nan_result);
if (a->sign != b->sign)
return -a->sign - -b->sign;
if (REAL_EXP (a) > REAL_EXP (b))
ret = 1;
else if (REAL_EXP (a) < REAL_EXP (b))
......
2017-05-17 Segher Boessenkool <segher@kernel.crashing.org>
PR middle-end/80692
* gcc.c-torture/execute/pr80692.c: New testcase.
2017-05-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/80741
......
/* { dg-require-effective-target dfp } */
int main () {
_Decimal64 d64 = -0.DD;
if (d64 != 0.DD)
__builtin_abort ();
if (d64 != -0.DD)
__builtin_abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment