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