From fafe9318b735a4b3276b39a73c42aef7a69249d1 Mon Sep 17 00:00:00 2001 From: Yuri Rumyantsev Date: Wed, 29 Jun 2016 10:16:43 +0000 Subject: [PATCH] re PR tree-optimization/70729 (Loop marked with omp simd pragma is not vectorized) gcc/ 2016-06-29 Yuri Rumyantsev PR tree-optimization/70729 * tree-ssa-loop-im.c (ref_indep_loop_p_1): Consider memory reference as independent in loops having positive safelen value. * tree-vect-loop.c (vect_transform_loop): Clear-up safelen value since it may be not valid after vectorization. gcc/testsuite/ 2016-06-29 Yuri Rumyantsev PR tree-optimization/70729 * g++.dg/vect/pr70729.cc: New test. From-SVN: r237844 --- gcc/ChangeLog | 8 +++ gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/vect/pr70729.cc | 78 ++++++++++++++++++++++++++++ gcc/tree-ssa-loop-im.c | 11 ++++ gcc/tree-vect-loop.c | 3 ++ 5 files changed, 105 insertions(+) create mode 100644 gcc/testsuite/g++.dg/vect/pr70729.cc diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d4f9b3f6e3..a0865246769 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-06-29 Yuri Rumyantsev + + PR tree-optimization/70729 + * tree-ssa-loop-im.c (ref_indep_loop_p_1): Consider memory reference as + independent in loops having positive safelen value. + * tree-vect-loop.c (vect_transform_loop): Clear-up safelen value since + it may be not valid after vectorization. + 2016-06-29 Jakub Jelinek PR tree-optimization/71625 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc85add977d..471e39a24e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-29 Yuri Rumyantsev + + PR tree-optimization/70729 + * g++.dg/vect/pr70729.cc: New test. + 2016-06-29 Thomas Schwinge * c-c++-common/gomp/cancel-1.c: Extend. diff --git a/gcc/testsuite/g++.dg/vect/pr70729.cc b/gcc/testsuite/g++.dg/vect/pr70729.cc new file mode 100644 index 00000000000..0d5d353faeb --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr70729.cc @@ -0,0 +1,78 @@ +// { dg-do compile } +// { dg-require-effective-target vect_simd_clones } +// { dg-additional-options "-Ofast" } +// { dg-additional-options "-mavx2 -fopenmp-simd" { target x86_64-*-* i?86-*-* } } + + +#include +#include + +inline void* my_alloc(size_t bytes) {return _mm_malloc(bytes, 128);} +inline void my_free(void* memory) {_mm_free(memory);} + +template +class Vec +{ + const int isize; + T* data; + +public: + + Vec (int n) : isize(n) {data = (T*)my_alloc(isize*sizeof(T));} + ~Vec () {my_free(data);} + + Vec& operator = (const Vec& other) + { + if (this != &other) + memcpy(data, other.data, isize*sizeof(T)); + return *this; + } + + T& operator [] (int i) {return data[i];} + const T& operator [] (int i) const {return data[i];} + T& at (int i) {return data[i];} + const T& at (int i) const {return data[i];} + + operator T* () {return data;} + int size () const {return isize;} +}; + +template +class Cl +{ +public: + + Cl (int n, int m); + const int N, M; + Vec v_x, v_y; + Vec v_i; + Vec v_z; +}; + +struct Ss +{ + const int S_n, S_m; + Cl v1; + float* C1; + float* C2; + Ss (int n1, int n2): S_n(n1), S_m(n2), v1(n1, n2) + { + C1 = new float[n1 * 3]; + C2 = new float[n2 * 4]; + } + + ~Ss () { delete C1; delete C2;} + void foo (float *in, float w); +}; +void Ss::foo (float *in, float w) +{ +#pragma omp simd + for (int i=0; isafelen > 0) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf(dump_file,"Consider REF independent in loop#%d\n", loop->num); + print_generic_expr(dump_file, ref->mem.ref, TDF_SLIM); + fprintf(dump_file, "\n"); + } + return true; + } + EXECUTE_IF_SET_IN_BITMAP (refs_to_check, 0, i, bi) { aref = memory_accesses.refs_list[i]; diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 6c0337bbbcb..5e4007642b7 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6968,6 +6968,9 @@ vect_transform_loop (loop_vec_info loop_vinfo) FOR_EACH_VEC_ELT (LOOP_VINFO_SLP_INSTANCES (loop_vinfo), i, instance) vect_free_slp_instance (instance); LOOP_VINFO_SLP_INSTANCES (loop_vinfo).release (); + /* Clear-up safelen field since its value is invalid after vectorization + since vectorized loop can have loop-carried dependencies. */ + loop->safelen = 0; } /* The code below is trying to perform simple optimization - revert -- 2.30.2