]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: bpabi.S (test_div_by_zero): Make label names consistent between thumb2...
authorSandra Loosemore <sandra@codesourcery.com>
Tue, 17 Feb 2015 17:44:18 +0000 (12:44 -0500)
committerSandra Loosemore <sandra@gcc.gnu.org>
Tue, 17 Feb 2015 17:44:18 +0000 (12:44 -0500)
2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>

libgcc/
Backported from mainline
2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>

* config/arm/bpabi.S (test_div_by_zero): Make label names
consistent between thumb2 and arm mode cases.  Separate the
signed comparison on the high word of the numerator from the
unsigned comparison on the low word.
* config/arm/bpabi-v6m.S (test_div_by_zero): Similarly separate
signed comparison.

gcc/testsuite/
Backported from mainline
2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>

* gcc.target/arm/divzero.c: New test case.

From-SVN: r220767

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/divzero.c [new file with mode: 0644]
libgcc/ChangeLog
libgcc/config/arm/bpabi-v6m.S
libgcc/config/arm/bpabi.S

index 7c79fd4df502e6aa644e4fbad9754b6269f8f09f..0d78836368e2f4a2b962805bf0bf65fb4f02a62f 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>
+
+       Backported from mainline
+       2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>
+
+       * gcc.target/arm/divzero.c: New test case.
+
 2015-02-17  Ilya Tocar  <ilya.tocar@intel.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.target/arm/divzero.c b/gcc/testsuite/gcc.target/arm/divzero.c
new file mode 100644 (file)
index 0000000..7d398a5
--- /dev/null
@@ -0,0 +1,85 @@
+/* { dg-require-effective-target arm_eabi } */
+/* { dg-options "" } */
+/* { dg-do run } */
+
+/* Check that long long divmod functions pass the right argument to
+   __aeabi_ldiv0 on divide by zero.  */
+
+#ifdef DEBUGME
+#include <stdio.h>
+#else
+extern void abort (void);
+#endif
+
+/* Override div zero handler and simply return the provided value.  */
+long long __aeabi_ldiv0 (long long r)
+{
+  return r;
+}
+
+long long lldiv (long long a, long long b)
+{
+  return a / b;
+}
+
+unsigned long long ulldiv (unsigned long long a, unsigned long long b)
+{
+  return a / b;
+}
+
+void check (long long num, long long expected)
+{
+  long long res = lldiv (num, 0LL);
+  if (res != expected)
+#ifdef DEBUGME
+    {
+      printf ("num=%08X:%08X\n", (unsigned)(num >> 32), (unsigned)num);
+      printf ("res=%08X:%08X\n", (unsigned)(res >> 32), (unsigned)res);
+    }
+#else
+    abort ();
+#endif
+}
+
+void ucheck (unsigned long long num, unsigned long long expected)
+{
+  unsigned long long res = ulldiv (num, 0ULL);
+  if (res != expected)
+#ifdef DEBUGME
+    {
+      printf ("num=%08X:%08X\n", (unsigned)(num >> 32), (unsigned)num);
+      printf ("res=%08X:%08X\n", (unsigned)(res >> 32), (unsigned)res);
+    }
+#else
+    abort ();
+#endif
+}
+
+#define POS_BIG 0x7fffffffffffffffLL
+#define NEG_BIG 0x8000000000000000LL
+#define UNS_BIG 0xffffffffffffffffULL
+
+int main ()
+{
+  check (0LL, 0LL);
+  check (1LL, POS_BIG);
+  check (0x000000007fffffffLL, POS_BIG);
+  check (0x00000000ffffffffLL, POS_BIG);
+  check (0x0000000100000000LL, POS_BIG);
+  check (POS_BIG, POS_BIG);
+  check (-1LL, NEG_BIG);
+  check (-0x000000007fffffffLL, NEG_BIG);
+  check (-0x00000000ffffffffLL, NEG_BIG);
+  check (-0x0000000100000000LL, NEG_BIG);
+  check (NEG_BIG, NEG_BIG);
+
+  ucheck (0ULL, 0ULL);
+  ucheck (1ULL, UNS_BIG);
+  ucheck (0x000000007fffffffULL, UNS_BIG);
+  ucheck (0x00000000ffffffffULL, UNS_BIG);
+  ucheck (0x0000000100000000ULL, UNS_BIG);
+  ucheck ((unsigned long long)POS_BIG, UNS_BIG);
+  ucheck (UNS_BIG, UNS_BIG);
+
+  return 0;
+}
index c2995c3b7afd75e875ca984aed72cc81fe5b36cf..7efaf4f2efa9de2a33eb8ff9301f0e10db84fdf8 100644 (file)
@@ -1,3 +1,15 @@
+2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>
+
+       Backported from mainline
+       2015-02-17  Sandra Loosemore  <sandra@codesourcery.com>
+
+       * config/arm/bpabi.S (test_div_by_zero): Make label names
+       consistent between thumb2 and arm mode cases.  Separate the
+       signed comparison on the high word of the numerator from the
+       unsigned comparison on the low word.
+       * config/arm/bpabi-v6m.S (test_div_by_zero): Similarly separate
+       signed comparison.
+
 2014-12-19  Release Manager
 
        * GCC 4.8.4 released.
index 2ad8f03748289461f123173a97d14e0f8cfb1af6..6da3682a48ee93f45b6261d183805da7b44c54d7 100644 (file)
@@ -85,19 +85,21 @@ FUNC_START aeabi_ulcmp
        cmp     yyl, #0
        bne     7f
        cmp     xxh, #0
+       .ifc    \signed, unsigned
        bne     2f
        cmp     xxl, #0
 2:
-       .ifc    \signed, unsigned
        beq     3f
        mov     xxh, #0
        mvn     xxh, xxh                @ 0xffffffff
        mov     xxl, xxh
 3:
        .else
-       beq     5f
        blt     6f
-       mov     xxl, #0
+       bgt     4f
+       cmp     xxl, #0
+       beq     5f
+4:     mov     xxl, #0
        mvn     xxl, xxl                @ 0xffffffff
        lsr     xxh, xxl, #1            @ 0x7fffffff
        b       5f
index d3493b357ca2ec85e43ec92dad9a2ff7d7846424..99df4a720b5ce2150bfba167ef9e5c94bca95921 100644 (file)
@@ -78,26 +78,29 @@ ARM_FUNC_START aeabi_ulcmp
 /* Tail-call to divide-by-zero handlers which may be overridden by the user,
    so unwinding works properly.  */
 #if defined(__thumb2__)
-       cbnz    yyh, 1f
-       cbnz    yyl, 1f
+       cbnz    yyh, 2f
+       cbnz    yyl, 2f
        cmp     xxh, #0
+       .ifc \signed, unsigned
        do_it   eq
        cmpeq   xxl, #0
-       .ifc \signed, unsigned
-       beq     2f
-       mov     xxh, #0xffffffff
-       mov     xxl, xxh
-2:
+       do_it   ne, t
+       movne   xxh, #0xffffffff
+       movne   xxl, #0xffffffff
        .else
-       do_it   lt, t
+       do_it   lt, tt
        movlt   xxl, #0
        movlt   xxh, #0x80000000
-       do_it   gt, t
-       movgt   xxh, #0x7fffffff
-       movgt   xxl, #0xffffffff
+       blt     1f
+       do_it   eq
+       cmpeq   xxl, #0
+       do_it   ne, t
+       movne   xxh, #0x7fffffff
+       movne   xxl, #0xffffffff
        .endif
+1:     
        b       SYM (__aeabi_ldiv0) __PLT__
-1:
+2:
 #else
        /* Note: Thumb-1 code calls via an ARM shim on processors which
           support ARM mode.  */
@@ -105,16 +108,19 @@ ARM_FUNC_START aeabi_ulcmp
        cmpeq   yyl, #0
        bne     2f
        cmp     xxh, #0
-       cmpeq   xxl, #0
        .ifc \signed, unsigned
+       cmpeq   xxl, #0
        movne   xxh, #0xffffffff
        movne   xxl, #0xffffffff
        .else
        movlt   xxh, #0x80000000
        movlt   xxl, #0
-       movgt   xxh, #0x7fffffff
-       movgt   xxl, #0xffffffff
+       blt     1f
+       cmpeq   xxl, #0
+       movne   xxh, #0x7fffffff
+       movne   xxl, #0xffffffff
        .endif
+1:
        b       SYM (__aeabi_ldiv0) __PLT__
 2:
 #endif