diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/strlenopt-26.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt-26.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/strlenopt-26.c b/gcc/testsuite/gcc.dg/strlenopt-26.c new file mode 100644 index 0000000..089355e --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt-26.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p, const char *r) +{ + size_t len1 = strlen (r); + char *q = strchr (p, '\0'); + *q = '\0'; + return len1 - strlen (r); // This strlen should be optimized into len1. +} + +int +main (void) +{ + char p[] = "foobar"; + const char *volatile q = "xyzzy"; + fn1 (p, q); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen" } } */ +/* { dg-final { cleanup-tree-dump "strlen" } } */ |