| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O3 -save-temps" } */ |
| 3 |
#include <stdint.h> |
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
#pragma GCC target "+nosve" |
| 7 |
|
| 8 |
#define ARR_SIZE 1024 |
| 9 |
|
| 10 |
/* Should produce an shll,shll2 pair*/ |
| 11 |
void sshll_opt (int32_t *foo, int16_t *a, int16_t *b) |
| 12 |
{ |
| 13 |
for( int i = 0; i < ARR_SIZE - 3;i=i+4) |
| 14 |
{ |
| 15 |
foo[i] = a[i] << 16; |
| 16 |
foo[i+1] = a[i+1] << 16; |
| 17 |
foo[i+2] = a[i+2] << 16; |
| 18 |
foo[i+3] = a[i+3] << 16; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
__attribute__((optimize (0))) |
| 23 |
void sshll_nonopt (int32_t *foo, int16_t *a, int16_t *b) |
| 24 |
{ |
| 25 |
for( int i = 0; i < ARR_SIZE - 3;i=i+4) |
| 26 |
{ |
| 27 |
foo[i] = a[i] << 16; |
| 28 |
foo[i+1] = a[i+1] << 16; |
| 29 |
foo[i+2] = a[i+2] << 16; |
| 30 |
foo[i+3] = a[i+3] << 16; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
void __attribute__((optimize (0))) |
| 36 |
init(uint16_t *a, uint16_t *b) |
| 37 |
{ |
| 38 |
for( int i = 0; i < ARR_SIZE;i++) |
| 39 |
{ |
| 40 |
a[i] = i; |
| 41 |
b[i] = 2*i; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
int __attribute__((optimize (0))) |
| 46 |
main() |
| 47 |
{ |
| 48 |
uint32_t foo_arr[ARR_SIZE]; |
| 49 |
uint32_t bar_arr[ARR_SIZE]; |
| 50 |
uint16_t a[ARR_SIZE]; |
| 51 |
uint16_t b[ARR_SIZE]; |
| 52 |
|
| 53 |
init(a, b); |
| 54 |
sshll_opt(foo_arr, a, b); |
| 55 |
sshll_nonopt(bar_arr, a, b); |
| 56 |
if (memcmp(foo_arr, bar_arr, ARR_SIZE) != 0) |
| 57 |
return 1; |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
/* { dg-final { scan-assembler-times {\tshll\t} 1} } */ |
| 62 |
/* { dg-final { scan-assembler-times {\tshll2\t} 1} } */ |