"unhandled use" in vectorizing a dot product?
Benjamin Redelings
benjamin_redelings@ncsu.edu
Mon Nov 30 23:24:00 GMT 2009
On 11/30/2009 05:37 PM, Tim Prince 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.
Thank you! I don't know how long it would have taken me to notice this.
Even better, I see that it can vectorize loops that marginalize
simultaneously multiple three numbers as well.
for(int i=0;i<16;i++)
sum += f1[i] * f2[i] * f3[i]?
Hmm... the point about -fassociative-math is a good point, presuming
that SSE math handles NaNs and Infs.
Also, perhaps the documentation should explicitly say somewhere that
vectorization can depend on flags like this. "unhandled use in
statement" certainly doesn't point the user to an idea of how to fix
this :-P
-BenRI
More information about the Gcc-help
mailing list