56d343
2017-06-27  Segher Boessenkool  <segher@kernel.crashing.org>
56d343
56d343
	Backport from trunk
56d343
	2017-05-17  Segher Boessenkool  <segher@kernel.crashing.org>
56d343
56d343
	PR middle-end/80692
56d343
	* real.c (do_compare): Give decimal_do_compare preference over
56d343
	comparing just the signs.
56d343
56d343
	* gcc.c-torture/execute/pr80692.c: New testcase.
56d343
56d343
--- gcc/real.c
56d343
+++ gcc/real.c
56d343
@@ -950,12 +950,12 @@ do_compare (const REAL_VALUE_TYPE *a, const REAL_VALUE_TYPE *b,
56d343
       gcc_unreachable ();
56d343
     }
56d343
 
56d343
-  if (a->sign != b->sign)
56d343
-    return -a->sign - -b->sign;
56d343
-
56d343
   if (a->decimal || b->decimal)
56d343
     return decimal_do_compare (a, b, nan_result);
56d343
 
56d343
+  if (a->sign != b->sign)
56d343
+    return -a->sign - -b->sign;
56d343
+
56d343
   if (REAL_EXP (a) > REAL_EXP (b))
56d343
     ret = 1;
56d343
   else if (REAL_EXP (a) < REAL_EXP (b))
56d343
--- /dev/null
56d343
+++ gcc/testsuite/gcc.c-torture/execute/pr80692.c
56d343
@@ -0,0 +1,11 @@
56d343
+int main () {
56d343
+	_Decimal64 d64 = -0.DD;
56d343
+
56d343
+	if (d64 != 0.DD)
56d343
+		__builtin_abort ();
56d343
+
56d343
+	if (d64 != -0.DD)
56d343
+		__builtin_abort ();
56d343
+
56d343
+	return 0;
56d343
+}
56d343
--- /dev/null
56d343
+++ gcc/testsuite/gcc.c-torture/execute/pr80692.x
56d343
@@ -0,0 +1,7 @@
56d343
+load_lib target-supports.exp
56d343
+
56d343
+if { ! [check_effective_target_dfp] } {
56d343
+        return 1
56d343
+}
56d343
+
56d343
+return 0