1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */ 3 4 #include <stdlib.h> 5 #define N 32 foo(int ustride,int size,float * src)6float *foo(int ustride, int size, float *src) 7 { 8 float *buffer, *p; 9 int i, k; 10 11 if (!src) 12 return NULL; 13 14 buffer = (float *) malloc(N * size * sizeof(float)); 15 16 if(buffer) 17 for(i=0, p=buffer; i<N; i++, src+=ustride) 18 for(k=0; k<size; k++) 19 *p++ = src[k]; 20 21 return buffer; 22 } 23 24 /* { dg-final { scan-tree-dump-times "guard hoisted" 1 "unswitch" } } */ 25 /* { dg-final { scan-tree-dump-not "Invalid sum" "unswitch" } } */ 26 27 28