AnsweredAssumed Answered

Simple loop vectorization giving wrong result

Question asked by p.p.santos on Mar 11, 2014
Latest reply on Mar 12, 2014 by CraigG

Hi,

 

I'm using VisualDSP++ 5.0 for SHARC 21369 EZ-kit with optimizations enabled for speed (maximum) and IPO.

 

I'm having a wrong result for the following simple loop when using vectorization:

 

for ( i = 0 ; i < 1000 ; i++ ) {

     a[i] = 200;

}

 

Which wrongly leads to: a = { 200 , 200 , 0 , 200 , 0 , 200 , 0 , 200 , 0 , 200 , 0 , 200 , 0 , ... , 200 , 0 , 200 }.

(I also looked at disassembly and could verify that it uses m = 2 and, therefore, skipped the even positions...)

 

But when I use no_vectorization pragma I get the right result:

 

#pragma no_vectorization

for ( i = 0 ; i < 1000 ; i++ ) {

     a[i] = 200;

}

 

Which leads to: a = { 200 , 200 , 200 , ... , 200 }.

 

What could be wrong?

 

Thanks,

 

Pedro Paulo.

Outcomes