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
This commit is contained in:
parent
78eca3093f
commit
e98e63404c
4 changed files with 27 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
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))
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
13
gcc/testsuite/gcc.c-torture/execute/pr80692.c
Normal file
13
gcc/testsuite/gcc.c-torture/execute/pr80692.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* { 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue