| 1 |
/* { dg-do run { target { riscv_v } } } */ |
| 2 |
/* { dg-additional-options "-O3 -minline-strlen" } */ |
| 3 |
|
| 4 |
int |
| 5 |
__attribute__ ((noipa)) |
| 6 |
foo (const char *s) |
| 7 |
{ |
| 8 |
return __builtin_strlen (s); |
| 9 |
} |
| 10 |
|
| 11 |
int |
| 12 |
__attribute__ ((noipa)) |
| 13 |
foo2 (const char *s) |
| 14 |
{ |
| 15 |
int n = 0; |
| 16 |
while (*s++ != '\0') |
| 17 |
{ |
| 18 |
asm volatile (""); |
| 19 |
n++; |
| 20 |
} |
| 21 |
return n; |
| 22 |
} |
| 23 |
|
| 24 |
#define SZ 10 |
| 25 |
|
| 26 |
int main () |
| 27 |
{ |
| 28 |
const char *s[SZ] |
| 29 |
= {"", "asdf", "0", "\0", "!@#$%***m1123fdnmoi43", |
| 30 |
"a", "z", "1", "9", "12345678901234567889012345678901234567890"}; |
| 31 |
|
| 32 |
for (int i = 0; i < SZ; i++) |
| 33 |
{ |
| 34 |
if (foo (s[i]) != foo2 (s[i])) |
| 35 |
__builtin_abort (); |
| 36 |
} |
| 37 |
} |