1 /* { dg-do compile } */
2 /* { dg-require-effective-target powerpc_pcrel } */
3 /* { dg-options "-O2 -mdejagnu-cpu=power10 -mpcrel-opt" } */
4
5 #define TYPE unsigned short
6 #define LARGE 0x20000
7
8 /* Test whether we get the right number of PCREL_OPT optimizations for unsigned
9 short. */
10 extern TYPE ext[];
11
12 TYPE
13 get (void)
14 {
15 return ext[0]; /* PCREL_OPT relocation. */
16 }
17
18 TYPE
19 get2 (void)
20 {
21 return ext[2]; /* PCREL_OPT relocation. */
22 }
23
24 TYPE
25 get_large (void)
26 {
27 return ext[LARGE]; /* No PCREL_OPT (load is prefixed). */
28 }
29
30 TYPE
31 get_variable (unsigned long n)
32 {
33 return ext[n]; /* No PCREL_OPT (load is indexed). */
34 }
35
36 double
37 get_double (void)
38 {
39 return (double) ext[0]; /* No PCREL_OPT (LXSIHZX is indexed). */
40 }
41
42 /* { dg-final { scan-assembler-times "R_PPC64_PCREL_OPT" 2 } } */