aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2015-02-17 12:39:22 -0500
committerSandra Loosemore <sandra@gcc.gnu.org>2015-02-17 12:39:22 -0500
commit53cfb467cf3da97a161f851a6e333e917cb96cec (patch)
tree9a2dd51186f5320995ccbaf23c8ab8afe5c540e6 /gcc
parent77d10a1b208d0e78ee638a49952276be9b830db4 (diff)
downloadgcc-53cfb467cf3da97a161f851a6e333e917cb96cec.zip
gcc-53cfb467cf3da97a161f851a6e333e917cb96cec.tar.gz
gcc-53cfb467cf3da97a161f851a6e333e917cb96cec.tar.bz2
bpabi.S (test_div_by_zero): Make label names consistent between thumb2 and arm mode cases.
2015-02-17 Sandra Loosemore <sandra@codesourcery.com> libgcc/ * 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/ * gcc.target/arm/divzero.c: New test case. From-SVN: r220765
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/arm/divzero.c85
2 files changed, 89 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1864240..9a2bb4b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-17 Sandra Loosemore <sandra@codesourcery.com>
+
+ * gcc.target/arm/divzero.c: New test case.
+
2015-02-17 Tom de Vries <tom@codesourcery.com>
* gcc.target/x86_64/abi/callabi/vaarg-6.c: New test.
diff --git a/gcc/testsuite/gcc.target/arm/divzero.c b/gcc/testsuite/gcc.target/arm/divzero.c
new file mode 100644
index 0000000..7d398a5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/divzero.c
@@ -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;
+}