OSDN Git Service

* gcc.dg/torture/builtin-modf-1.c: Remove -funsafe-math-optimizations.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / mips-hilo-1.c
1 /* f1 checks that an mtlo is not moved before an mfhi.  f2 does the same
2    for an mthi and an mflo.  */
3 /* { dg-do run { target mips*-*-* } } */
4 /* { dg-options "-mtune=rm7000" } */
5
6 extern void abort (void);
7 extern void exit (int);
8
9 #define DECLARE(TYPE)                                                   \
10   TYPE __attribute__ ((noinline)) __attribute__ ((nomips16))            \
11   f1##TYPE (TYPE x1, TYPE x2, TYPE x3)                                  \
12   {                                                                     \
13     TYPE t1, t2;                                                        \
14                                                                         \
15     asm ("mult\t%1,%2" : "=h" (t1) : "d" (x1), "d" (x2) : "lo");        \
16     asm ("mflo\t%0" : "=r" (t2) : "l" (x3) : "hi");                     \
17     return t1 + t2;                                                     \
18   }                                                                     \
19                                                                         \
20   TYPE __attribute__ ((noinline)) __attribute__ ((nomips16))            \
21   f2##TYPE (TYPE x1, TYPE x2, TYPE x3)                                  \
22   {                                                                     \
23     TYPE t1, t2;                                                        \
24                                                                         \
25     asm ("mult\t%1,%2" : "=l" (t1) : "d" (x1), "d" (x2) : "hi");        \
26     asm ("mfhi\t%0" : "=r" (t2) : "h" (x3) : "lo");                     \
27     return t1 + t2;                                                     \
28   }
29
30 #define TEST(TYPE)                                                      \
31   if (f1##TYPE (1, 2, 10) != 10)                                        \
32     abort ();                                                           \
33   if (f2##TYPE (1, 2, 40) != 42)                                        \
34     abort ()
35
36 typedef char c;
37 typedef signed char sc;
38 typedef unsigned char uc;
39 typedef short s;
40 typedef unsigned short us;
41 typedef int i;
42 typedef unsigned int ui;
43 typedef long long ll;
44 typedef unsigned long long ull;
45
46 DECLARE (c)
47 DECLARE (sc)
48 DECLARE (uc)
49 DECLARE (s)
50 DECLARE (us)
51 DECLARE (i)
52 DECLARE (ui)
53 #if defined (__mips64)
54 DECLARE (ll)
55 DECLARE (ull)
56 #endif
57
58 int
59 main ()
60 {
61   TEST (c);
62   TEST (sc);
63   TEST (uc);
64   TEST (s);
65   TEST (us);
66   TEST (i);
67   TEST (ui);
68 #if defined (__mips64)
69   TEST (ll);
70   TEST (ull);
71 #endif
72   exit (0);
73 }