1 /* { dg-do compile } */
2 /* { dg-options "-mgp64" } */
3 /* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */
4 
5 #define TEST(ID, TYPE1, TYPE2)					\
6   union u##ID {							\
7     TYPE1 m1[sizeof (TYPE2) / sizeof (TYPE1)];			\
8     TYPE2 m2;							\
9   };								\
10 								\
11   /* The MIPS16 versions of the shifts we need are too		\
12      expensive.  */						\
13   TYPE1 __attribute__((nomips16))				\
14   f##ID (TYPE2 x, union u##ID *u)				\
15   {								\
16     u->m2 = x;							\
17     return (u->m1[0]						\
18 	    + u->m1[sizeof (TYPE2) / sizeof (TYPE1) - 1]);	\
19   }								\
20 								\
21   TYPE1 __attribute__((nomips16))				\
22   g##ID (union u##ID *u)					\
23   {								\
24     u->m2 = 0;							\
25     return (u->m1[0] | u->m1[1]);				\
26   }
27 
28 TEST (1, unsigned int, unsigned long long);
29 TEST (2, int, long long);
30 TEST (3, unsigned short, unsigned long long);
31 TEST (4, short, long long);
32 TEST (5, unsigned char, unsigned long long);
33 TEST (6, signed char, long long);
34 
35 TEST (7, unsigned short, unsigned int);
36 TEST (8, short, int);
37 TEST (9, unsigned char, unsigned int);
38 TEST (10, signed char, int);
39 
40 TEST (11, unsigned char, unsigned short);
41 TEST (12, signed char, short);
42 
43 /* { dg-final { scan-assembler-not "\tlh\t" } } */
44 /* { dg-final { scan-assembler-not "\tlhu\t" } } */
45 /* { dg-final { scan-assembler-not "\tlw\t" } } */
46 /* { dg-final { scan-assembler-not "\tlwu\t" } } */
47 /* { dg-final { scan-assembler-not "\tlb\t" } } */
48 /* { dg-final { scan-assembler-not "\tlbu\t" } } */
49