I very much agree. Some programs require correctness with respect to inf and NaN, but would be quite happy with reordered arithmetic. Brian On Mon, Nov 30, 2009 at 2:37 PM, Tim Prince <n8tm@xxxxxxx> wrote: > Benjamin Redelings I wrote: > >> I noticed that (in gcc 4.5 as of Oct-18) the following code is not >> vectorized: >> >> float sum=0; >> int i; >> for(i=0;i<16;i++) >> sum += f1[i]*f2[i]; >> >> The error is "unhandled use in statement" >> >> However, the web page at >> http://gcc.gnu.org/projects/tree-ssa/vectorization.html says: >> >> "Detection and vectorization of special idioms, such as dot-product and >> widening-summation: Incorporated into GCC 4.2." >> >> Can you tell me if I am missing something? Is the web page correct? > > I haven't seen vector sum or dot product reduction except with the use of > -ffast-math. At one time, it was said that -fassociative-math also should > permit it. It's more effective with -mtune=barcelona (particularly for CPUs > introduced the last 2 years). > With those options, gcc/g++/gfortran are fairly good at dot product > vectorization, both traditional code such as you show, and > dot_product/inner_product. > In my opinion, it's unfortunate not having an option to enable this > optimization independent of riskier ones. >