[Bug c/60220] New: Vectorization : simple loop : fails to vectorize
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60220 Bug ID: 60220 Summary: Vectorization : simple loop : fails to vectorize Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: harmeeksingh at gmail dot com #include #include #define FALSE ((char )0) struct test { int*copy; }; typedef struct test test; void foo(test *__restrict c, unsigned int a, unsigned int num) { unsigned int cnt; for (cnt = 0; cnt < num ; cnt++) c->copy[cnt] = FALSE; for (cnt = 0; cnt < num ; cnt++) printf("%u \n", c->copy[cnt]); } $ gcc -ggdb -O6 -march=native -pipe -fno-strict-aliasing -funroll-all-loops -fpeel-loops -unroll-loops --param max-unroll-times=4 -ffast-math -fpeel-loops -fwrapv -fPIC -pthread -rdynamic -DCLS=64 -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -ftree-vectorize -ftree-vectorizer-verbose=7 -fgraphite-identity -falign-functions=4 -falign-loops=4 -falign-jumps=4 -fexpensive-optimizations -frerun-cse-after-loop -frerun-loop-opt -finline-functions -o /tmp/x.o -c /tmp/x.c Analyzing loop at /tmp/x.c:18 18: not vectorized: loop contains function calls or data references that cannot be analyzed Analyzing loop at /tmp/x.c:16 16: not vectorized: data ref analysis failed *D.2523_9 = 0; 16: not vectorized: data ref analysis failed *D.2523_9 = 0; /tmp/x.c:13: note: vectorized 0 loops in function. Gcc - version $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC)
[Bug c/60220] Vectorization : simple loop : fails to vectorize
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60220 --- Comment #3 from harmeeksingh at gmail dot com --- It still does not vectorise after adding the recomended flag. But rewriting the code the following way does. This is a bizare behavioir . My tests show that this is not an issue of gcc rewriting it as a memset . If I change the value 0 to a array assignment it still gives. From the output it does show that it is trying to assign FALSE. 31: not vectorized: data ref analysis failed *D.2549_9 = 0; 31: not vectorized: data ref analysis failed *D.2549_9 = 0; #include #include #define FALSE ((char )0) struct test { int*copy; }; typedef struct test test; static inline foo1(int *a, unsigned int num) { unsigned int cnt; for (cnt = 0; cnt < num ; cnt++) a[cnt] = FALSE; } typedef uintptr_t Datum; void foo(test *__restrict c, unsigned int a, unsigned int num) { foo1(c->copy, num); // This vectorizes. if we pass it to inline function }
[Bug c/61938] New: Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 Bug ID: 61938 Summary: Vectorization not happening . Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: harmeeksingh at gmail dot com $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC) Testcase #include #define VEC 1024 typedef long int int64; typedef int int32; void foo (int arraysize, int *result, int *selectvector, int selectelements, int32 *array, int32 compval) { int k, i; for (k =0,i=0; i < selectelements; ++i) { result[k] = selectvector[i]; k += (((array[selectvector[i]])) == compval); } } main() { int result[VEC]; int selectvector[VEC]; int selectelements; int32 array[VEC]; int k, i; foo(VEC, &result[0], &selectvector[0], VEC, &array[0], 1); } Compilation log gcc -fPIC -ggdb -O3 -march=native -ftree-vectorize -ftree-vectorizer-verbose=7 /tmp/x.c -o /tmp/x Analyzing loop at /tmp/x.c:17 17: not vectorized: data ref analysis failed *D.2502_9 = D.2506_14; 17: not vectorized: data ref analysis failed *D.2502_9 = D.2506_14; /tmp/x.c:9: note: vectorized 0 loops in function.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #3 from harmeeksingh at gmail dot com --- #include #define VEC 1024 typedef long int int64; typedef int int32; void foo (int arraysize, int *__restrict result, int *__restrict selectvector, int selectelements, int64 *__restrict array, int64 compval) { int k, i; for (k =0,i=0; i < arraysize; ++i) { result[k] = i; k += (array[i] == compval); } } main() { int result[VEC]; int selectvector[VEC]; int selectelements; int64 array[VEC]; int k, i; foo(VEC, result, selectvector, VEC, array, 1); } Even the above does not vectorize gcc -fPIC -shared -DCLS=64 -ffast-math -mfpmath=sse -mmmx -msse -msse2 -ftree-vectorize -ftree-vectorizer-verbose=7 -O3 -march=native /tmp/x.c -o /tmp/x Analyzing loop at /tmp/x.c:17 17: not vectorized: data ref analysis failed *D.2502_9 = i_27; /tmp/x.c:9: note: vectorized 0 loops in function.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #6 from harmeeksingh at gmail dot com --- Equivalent code when written by hand where tmp is a intermediate array . The compiler vectorizes both loops. int k, i; /* vectorize the compares */ for (i=0; i < arraysize; ++i) { tmp[i] = (array[i] == compval); } /* another loop now set the result array */ for (k=0, i=0; i < arraysize; ++i) { if (tmp[i]) { result[k] = i; k++; } }