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