decimal_real_maxval misses to set the sign flag in the REAL_VALUE_TYPE.
gcc/ChangeLog:
PR rtl-optimization/97439
* dfp.c (decimal_real_maxval): Set the sign flag in the
generated number.
gcc/testsuite/ChangeLog:
* gcc.dg/dfp/pr97439.c: New test.
decimal_real_from_string (r, max);
if (sign)
decimal128SetSign ((decimal128 *) r->sig, 1);
+
+ r->sign = sign;
}
--- /dev/null
+// { dg-do run }
+// { dg-options "-O1" }
+
+static int
+foo(_Decimal128 x, _Decimal128 y)
+{
+ if (x > y)
+ return 1;
+
+ return 0;
+}
+
+int __attribute__((noinline))
+bar(_Decimal128 x)
+{
+ return foo (x, -1.0DL * __builtin_infd32());
+}
+
+int
+main (void)
+{
+ int res = bar (0.0DL);
+ if (res != 1)
+ __builtin_abort ();
+
+ return 0;
+}