diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/loop-unswitch-3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/loop-unswitch-3.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-3.c b/gcc/testsuite/gcc.dg/loop-unswitch-3.c new file mode 100644 index 0000000..e355286 --- /dev/null +++ b/gcc/testsuite/gcc.dg/loop-unswitch-3.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */ + +#include <stdlib.h> +#define N 32 +float *foo(int ustride, int size, float *src) +{ + float *buffer, *p; + int i, k; + + if (!src) + return NULL; + + buffer = (float *) malloc(N * size * sizeof(float)); + + if(buffer) + for(i=0, p=buffer; i<N; i++, src+=ustride) + for(k=0; k<size; k++) + *p++ = src[k]; + + return buffer; +} + +/* { dg-final { scan-tree-dump-times "guard hoisted" 1 "unswitch" } } */ + + |