This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/38525] sse2(int16) code fails with -O3



------- Comment #7 from leonid at volnitsky dot com  2008-12-14 22:32 -------
(In reply to comment #2)
> ... please reduce your source to a
> short, self contained runtime testcase (in plain C if possible) that fails with
> certain compile flags.

I've tried to do that (see below).  But unfortunately it does not exhibit same
behavior. It will fail on any optimized compile with warning about aliasing.
Which is fixable by adding -fno-strict-aliasing. Don't know if this is related
on not. 

---------------------------------------------------------
#include <immintrin.h>
#include <stdio.h>

int main(int argc, char *argv[]) {

        int16_t  volatile A[2000];    
        for (int i=0; i<(2000-2); i+=2) { A[i]=1;  A[i+1]=2; };  A[333] = 3; 

         #define mk_m128i(x) *(__m128i*)&(x)
        __m128i m1 = mk_m128i(A[0]);
        __m128i m2 = mk_m128i(A[8]);

        for (int i= 16;  i < 2000-16; i+=16) {                  // SSE
                 m1 = _mm_max_epi16(m1, mk_m128i(A[i]) ); 
                 m2 = _mm_max_epi16(m2, mk_m128i(A[i+8]) ); 
        }  

        m1 = _mm_max_epi16(m1, m2);

        int16_t* ip  = (int16_t*)&m1;  
        printf("%hi %hi %hi %hi  %hi %hi %hi %hi \n", *ip++, *ip++, *ip++,
*ip++, *ip++, *ip++, *ip++, *ip);       

return 0;                                                                       
 }




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]