| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-ifunc "" } */ |
| 3 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 4 |
|
| 5 |
__attribute__ ((target ("default"))) |
| 6 |
static unsigned foo(const char *buf, unsigned size) { |
| 7 |
return 1; |
| 8 |
} |
| 9 |
|
| 10 |
__attribute__ ((target ("avx"))) |
| 11 |
static unsigned foo(const char *buf, unsigned size) { |
| 12 |
return 2; |
| 13 |
} |
| 14 |
|
| 15 |
__attribute__ ((target ("default"))) |
| 16 |
unsigned bar() { |
| 17 |
char buf[4096]; |
| 18 |
unsigned acc = 0; |
| 19 |
for (int i = 0; i < sizeof(buf); i++) { |
| 20 |
acc += foo(&buf[i], 1); |
| 21 |
} |
| 22 |
return acc; |
| 23 |
} |
| 24 |
|
| 25 |
__attribute__ ((target ("avx"))) |
| 26 |
unsigned bar() { |
| 27 |
char buf[4096]; |
| 28 |
unsigned acc = 0; |
| 29 |
for (int i = 0; i < sizeof(buf); i++) { |
| 30 |
acc += foo(&buf[i], 1); |
| 31 |
} |
| 32 |
return acc; |
| 33 |
} |
| 34 |
|
| 35 |
/* { dg-final { scan-tree-dump-times "return 4096;" 1 "optimized" } } */ |
| 36 |
/* { dg-final { scan-tree-dump-times "return 8192;" 1 "optimized" } } */ |