The following type of dependence, similar to such that would be created by predictive commoning (or even PRE), is not supported by the vectorizer: for (i = 1; i <= i_2; ++i) { a[i] = (b[i] + x) * .5f; x = b[i]; }
Indeed. Proper testcase: float res[1024], data[1024]; void foo(void) { int i; float tmp = data[0]; for (i = 1; i < 1024; ++i) { float tmp2 = data[i]; res[i] = tmp + tmp2; tmp = tmp2; } } manually "optimized" from res[i] = data[i] + data[i-1];
Or like the following, which is just a bunch of reductions of two elements float data[1024]; void foo(void) { int i; for (i = 1; i < 1024; ++i) data[i] = data[i] + data[i-1]; }
(In reply to comment #2) > Or like the following, which is just a bunch of reductions of two elements > float data[1024]; > void foo(void) > { > int i; > for (i = 1; i < 1024; ++i) > data[i] = data[i] + data[i-1]; > } Actually, this loop is not vectorizable. res and data have to be different arrays, otherwise we get read after write dependence with distance 1. Ira
Subject: Bug 35229 Author: matz Date: Wed Jul 22 15:30:50 2009 New Revision: 149942 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149942 Log: PR tree-optimization/35229 PR tree-optimization/39300 * tree-ssa-pre.c (includes): Include tree-scalar-evolution.h. (inhibit_phi_insertion): New function. (insert_into_preds_of_block): Call it for REFERENCEs. (init_pre): Initialize and finalize scalar evolutions. * Makefile.in (tree-ssa-pre.o): Depend on tree-scalar-evolution.h . testsuite/ * gcc.dg/vect/vect-pre-interact.c: New test. Added: trunk/gcc/testsuite/gcc.dg/vect/vect-pre-interact.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-pre.c
*** Bug 43425 has been marked as a duplicate of this bug. ***
*** Bug 57223 has been marked as a duplicate of this bug. ***
*** Bug 56595 has been marked as a duplicate of this bug. ***
Still happens for partially loop invariant loads (partially loop invariant as in blocked by a following aliasing store in the loop body). Like seen in PR57223.