| 1 |
/* Check that GCC generates Armv8.1-M low over head loop instructions |
| 2 |
for some simple loops. */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-require-effective-target arm_v8_1m_lob_hw } */ |
| 5 |
/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ |
| 6 |
/* { dg-options "-march=armv8.1-m.main -mthumb -O3 --save-temps" } */ |
| 7 |
#include <stdlib.h> |
| 8 |
#include "lob.h" |
| 9 |
|
| 10 |
int a[N]; |
| 11 |
int b[N]; |
| 12 |
int c[N]; |
| 13 |
|
| 14 |
int |
| 15 |
foo (int a, int b) |
| 16 |
{ |
| 17 |
return a + b; |
| 18 |
} |
| 19 |
|
| 20 |
void __attribute__((noinline)) |
| 21 |
loop1 (int *a, int *b, int *c) |
| 22 |
{ |
| 23 |
for (int i = 0; i < N; i++) |
| 24 |
{ |
| 25 |
a[i] = i; |
| 26 |
b[i] = i * 2; |
| 27 |
c[i] = a[i] + b[i]; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void __attribute__((noinline)) |
| 32 |
loop2 (int *a, int *b, int *c) |
| 33 |
{ |
| 34 |
int i = 0; |
| 35 |
while (i < N) |
| 36 |
{ |
| 37 |
a[i] = i - 2; |
| 38 |
b[i] = i * 5; |
| 39 |
c[i] = a[i] + b[i]; |
| 40 |
i++; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
void __attribute__((noinline)) |
| 45 |
loop3 (int *a, int *b, int *c) |
| 46 |
{ |
| 47 |
int i = 0; |
| 48 |
do |
| 49 |
{ |
| 50 |
a[i] = i - 4; |
| 51 |
b[i] = i * 3; |
| 52 |
c[i] = a[i] + b[i]; |
| 53 |
i++; |
| 54 |
} while (i < N); |
| 55 |
} |
| 56 |
|
| 57 |
int |
| 58 |
main (void) |
| 59 |
{ |
| 60 |
reset_data (a, b, c, N); |
| 61 |
loop1 (a, b ,c); |
| 62 |
check_plus (a, b, c, N); |
| 63 |
reset_data (a, b, c, N); |
| 64 |
loop2 (a, b ,c); |
| 65 |
check_plus (a, b, c, N); |
| 66 |
reset_data (a, b, c, N); |
| 67 |
loop3 (a, b ,c); |
| 68 |
check_plus (a, b, c, N); |
| 69 |
|
| 70 |
return 0; |
| 71 |
} |
| 72 |
|
| 73 |
/* { dg-final { scan-assembler-times {dls\s\S*,\s\S*} 3 } } */ |
| 74 |
/* { dg-final { scan-assembler-times {le\slr,\s\S*} 3 } } */ |