Bug 18074 - SSE2 intrinsics generates wrong code
Summary: SSE2 intrinsics generates wrong code
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-10-20 11:35 UTC by Chih-Chung Chang
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chih-Chung Chang 2004-10-20 11:35:45 UTC
The command line: gcc -O2 -msse2 -S 2.c
The code:
#include <emmintrin.h>
int f(__m128i x, __m128i y)
{
  __m128i m[1];
  m[0] = _mm_add_epi16(x, y);
  return *(int*)(&m[0]);
}
int g(__m128i x, __m128i y)
{
  __m128i m[2];
  m[0] = _mm_add_epi16(x, y);
  return *(int*)(&m[0]);
}

The compiler generates correct code for f(),
but for g() the add operation (paddw) disappears.
Happens on GCC 3.3.4 and 3.4.2
Comment 1 Andrew Pinski 2004-10-20 11:59:14 UTC
Either use an union to extract the component or use -fno-strict-aliasing.
Comment 2 Andrew Pinski 2004-10-20 11:59:41 UTC
Either use an union to extract the component or use -fno-strict-aliasing.

You are violating aliasing rules.
Comment 3 Andrew Pinski 2005-06-05 09:01:55 UTC
Reopening to ...
Comment 4 Andrew Pinski 2005-06-05 09:02:14 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***