https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98176
Bug ID: 98176 Summary: Loop invariant memory could not be hoisted when nonpure_call in loop body Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: wwwhhhyyy333 at gmail dot com Target Milestone: --- For testcase #include <cmath> void foo(float *x, float tx, float *ret, int n) { #pragma omp simd for (int i = 0; i < n; i++) { float s,c; sincosf(x[i] * tx, &s, &c); *ret += s * c; } } It could not be vectorized with -Ofast -fopenmp-simd -std=c++11 https://gcc.godbolt.org/z/ba77az By manually hoist it could be vectorized with simd clone void foo(float *x, float tx, float *ret, int n) { float tmp = 0.0f; #pragma omp simd for (int i = 0; i < n; i++) { float s,c; sincosf(x[i] * tx, &s, &c); tmp += s*c; } *ret += tmp; } https://gcc.godbolt.org/z/bea17x Is it possible for lim to perform store motion on case like this?