* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
@ 2008-12-14 16:54 ` leonid at volnitsky dot com
2008-12-14 19:30 ` ubizjak at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: leonid at volnitsky dot com @ 2008-12-14 16:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from leonid at volnitsky dot com 2008-12-14 16:52 -------
Created an attachment (id=16907)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16907&action=view)
u-array.ii
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 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
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2008-12-14 19:30 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 684 bytes --]
------- Comment #2 from ubizjak at gmail dot com 2008-12-14 19:29 -------
I can't compile the attachment:
g++ -O3 -fpreprocessed u-array.ii
In file included from /home/lvv/p/lvv/sse.h:23,
from /home/lvv/p/lvv/array.h:35,
from u-array.cc:10:
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h: In
function float __vector__ _mm_addsub_ps(float __vector__, float __vector__):
[...]
However, since you already found a failing test, please reduce your source to a
short, self contained runtime testcase (in plain C if possible) that fails with
certain compile flags.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 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
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2008-12-14 19:32 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 793 bytes --]
------- Comment #3 from ubizjak at gmail dot com 2008-12-14 19:31 -------
(In reply to comment #2)
> /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h: In
> function float __vector__ _mm_addsub_ps(float __vector__, float __vector__):
g++ -O3 -fpreprocessed u-array.ii
In file included from /home/lvv/p/lvv/sse.h:23,
from /home/lvv/p/lvv/array.h:35,
from u-array.cc:10:
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h: In
function float __vector__ _mm_addsub_ps(float __vector__, float __vector__):
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h:53:
error: __builtin_ia32_addsubps was not declared in this scope
[...]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-12-14 19:58 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]
------- Comment #4 from hjl dot tools at gmail dot com 2008-12-14 19:57 -------
(In reply to comment #3)
> (In reply to comment #2)
>
> > /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h: In
> > function �float __vector__ _mm_addsub_ps(float __vector__, float __vector__)�:
>
> g++ -O3 -fpreprocessed u-array.ii
> In file included from /home/lvv/p/lvv/sse.h:23,
> from /home/lvv/p/lvv/array.h:35,
> from u-array.cc:10:
> /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h: In
> function �float __vector__ _mm_addsub_ps(float __vector__, float __vector__)�:
> /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/pmmintrin.h:53:
> error: �__builtin_ia32_addsubps� was not declared in this scope
> [...]
>
You need to use -march=core2 to enable SSSE3.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl dot tools at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-12-14 20:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2008-12-14 19:59 -------
(In reply to comment #1)
> Created an attachment (id=16907)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16907&action=view) [edit]
> u-array.ii
>
Please extract the failed ones to create a smaller testcase.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (4 preceding siblings ...)
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
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: leonid at volnitsky dot com @ 2008-12-14 21:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from leonid at volnitsky dot com 2008-12-14 21:00 -------
Created an attachment (id=16910)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16910&action=view)
Trimmed unit test. Only one, relevant to bug test
--
leonid at volnitsky dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #16907|0 |1
is obsolete| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (5 preceding siblings ...)
2008-12-14 21:02 ` leonid at volnitsky dot com
@ 2008-12-14 22:33 ` leonid at volnitsky dot com
2008-12-16 0:05 ` pinskia at gcc dot gnu dot org
2008-12-16 13:22 ` leonid at volnitsky dot com
8 siblings, 0 replies; 10+ messages in thread
From: leonid at volnitsky dot com @ 2008-12-14 22:33 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (6 preceding siblings ...)
2008-12-14 22:33 ` leonid at volnitsky dot com
@ 2008-12-16 0:05 ` pinskia at gcc dot gnu dot org
2008-12-16 13:22 ` leonid at volnitsky dot com
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-16 0:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pinskia at gcc dot gnu dot org 2008-12-16 00:03 -------
int16_t* ip = (int16_t*)&m1;
printf("%hi %hi %hi %hi %hi %hi %hi %hi \n", *ip++, *ip++, *ip++,
*ip++, *ip++, *ip++, *ip++, *ip);
That is violating C/C++ aliasing rules even if __m128i is marked with
may_alias, the type you are accessing via is not marked as such.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/38525] sse2(int16) code fails with -O3
2008-12-14 16:49 [Bug c++/38525] New: sse2(int16) code fails with -O3 leonid at volnitsky dot com
` (7 preceding siblings ...)
2008-12-16 0:05 ` pinskia at gcc dot gnu dot org
@ 2008-12-16 13:22 ` leonid at volnitsky dot com
8 siblings, 0 replies; 10+ messages in thread
From: leonid at volnitsky dot com @ 2008-12-16 13:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from leonid at volnitsky dot com 2008-12-16 13:21 -------
(In reply to comment #8)
>> int16_t* ip = (int16_t*)&m1;
> That is violating C/C++ aliasing rules
The code that you quote is not part of the reported bug. It was quick and
dirty hack. But that was it. Adding -fno-strict-aliasing fixed unit tests.
But then there is a question. Full code attached to the bug does not gave any
warning about aliasing violation with -Wall and -O3. Is no-warning a bug?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38525
^ permalink raw reply [flat|nested] 10+ messages in thread