简体   繁体   中英

Vectorize short to float conversion?

I am trying to understand why Visual Studio 2012 (x64) doesn't want to vectorized a conversion from a short to a float . Does anybody have a reason or a way around?

//unsigned short* __restrict A,B,C,D    
for (int j = 0; j < H*W;j++) 
{
    float Gs = D[j]-B[j];
    float Gc = A[j]-C[j];
    in[j]=atan2f(Gs,Gc);
}

info C5002: loop not vectorized due to reason '1101'

RESOLUTION

Runtime using shorts and not vectorizing is about 800ms

Runtime converting to all ints and auto vectorizing is about 140ms (!!!)

From this page , it appears that your "Loop contains a non-vectorizable conversion operation (may be implicit)". Have you tried first converting to a type which is the same width as a float (such as int )?

For a more concrete reason, see here . Apparently, there is no direct way in SSE to convert an SSE register consisting of a vector of shorts to a vector of floats, however there is an instruction that converts 32-bit integers to floats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM