]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.
authorGeorg-Johann Lay <avr@gjlay.de>
Thu, 9 Oct 2025 13:27:16 +0000 (15:27 +0200)
committerGeorg-Johann Lay <avr@gjlay.de>
Thu, 9 Oct 2025 19:55:10 +0000 (21:55 +0200)
PR target/122220
libgcc/config/avr/libf7/
* libf7-asm.sx (to_integer): Return 0x80... on negative overflow.

gcc/testsuite/
* gcc.target/avr/pr122220.c: New test.

gcc/testsuite/gcc.target/avr/pr122220.c [new file with mode: 0644]
libgcc/config/avr/libf7/libf7-asm.sx

diff --git a/gcc/testsuite/gcc.target/avr/pr122220.c b/gcc/testsuite/gcc.target/avr/pr122220.c
new file mode 100644 (file)
index 0000000..2a8b839
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run { target { ! avr_tiny } } } */
+/* { dg-additional-options { -std=gnu99 -Os -mcall-prologues } } */
+
+#if __SIZEOF_LONG_DOUBLE__ == 8
+
+typedef long double D;
+typedef __INT32_TYPE__ int32_t;
+
+D dd = -0x1p31L;
+  
+int main (void)
+{
+  if ((int32_t) dd != -0x7fffffff - 1)
+    __builtin_abort();
+
+  return 0;
+}
+#else
+int main (void)
+{
+  return 0;
+}
+#endif
index 4b42947e2ed6463fe424ace06cd568f2721dad87..a0f9bacf5fe16a04c81fba0e100dcd9cd99e3591 100644 (file)
@@ -618,21 +618,7 @@ DEFUN to_integer
 .Lsaturate.T:
 
 #if F7_HAVE_Inf
-    brtc .Lset_0x7fff
-    ;; -Inf  =>  return 1 + INTxx_MIN
-    mov     ZL,     Flags
-    .global __clr_8
-    XCALL   __clr_8
-    ldi     C6,     0x80
-
-    ldi     CA+0,   0x01
-
-    sbrs    Mask,   5
-    ldi     CA+4,   0x01
-
-    sbrs    Mask,   4
-    ldi     CA+6,   0x01
-    ret
+    brts .Lset_0x8000
 
 .Lset_0x7fff:
     ;; +Inf  =>  return INTxx_MAX
@@ -644,7 +630,7 @@ DEFUN to_integer
 #endif /* F7_HAVE_Inf */
 
 .Lset_0x8000:
-    ;; NaN  =>  return INTxx_MIN
+    ;; NaN  or -Inf =>  return INTxx_MIN
     .global __clr_8
     XCALL   __clr_8
     ldi     C6,     0x80