public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "leonid at volnitsky dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/38525] sse2(int16) code fails with -O3
Date: Sun, 14 Dec 2008 22:33:00 -0000	[thread overview]
Message-ID: <20081214223217.12129.qmail@sourceware.org> (raw)
In-Reply-To: <bug-38525-17077@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2008-12-14 22:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-14 16:49 [Bug c++/38525] New: " leonid at volnitsky dot com
2008-12-14 16:54 ` [Bug c++/38525] " leonid at volnitsky dot com
2008-12-14 19:30 ` ubizjak at gmail dot com
2008-12-14 19:32 ` ubizjak at gmail dot com
2008-12-14 19:58 ` hjl dot tools at gmail dot com
2008-12-14 20:00 ` hjl dot tools at gmail dot com
2008-12-14 21:02 ` leonid at volnitsky dot com
2008-12-14 22:33 ` leonid at volnitsky dot com [this message]
2008-12-16  0:05 ` pinskia at gcc dot gnu dot org
2008-12-16 13:22 ` leonid at volnitsky dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081214223217.12129.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).