public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory
@ 2008-11-04 22:40 jch at pps dot jussieu dot fr
2008-11-04 22:49 ` [Bug target/38015] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jch at pps dot jussieu dot fr @ 2008-11-04 22:40 UTC (permalink / raw)
To: gcc-bugs
Consider the following function, which adds 1 to its argument using Intel
intrinsics:
#include <emmintrin.h>
unsigned
add1(unsigned x)
{
__m128i a = _mm_cvtsi32_si128(x);
__m128i b = _mm_add_epi32(a, _mm_set_epi32(0, 0, 0, 1));
return _mm_cvtsi128_si32(b);
}
GCC goes through memory no less than three times: once when converting x to a
vector, once when converting 1 to a vector, and once when converting the result
back to an integer:
add1:
pxor %xmm0, %xmm0
movq %rdi, -16(%rsp)
movq -16(%rsp), %xmm1
movss %xmm1, %xmm0
paddd .LC0(%rip), %xmm0
movd %xmm0, -4(%rsp)
movl -4(%rsp), %eax
ret
For comparison, here is the code generated by the Intel compiler:
add1:
movl $1, %edx
movd %edi, %xmm1
movd %edx, %xmm0
paddd %xmm0, %xmm1
movd %xmm1, %eax
ret
--
Summary: Converting between int and vector using intrinsics goes
through memory
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jch at pps dot jussieu dot fr
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38015
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/38015] Converting between int and vector using intrinsics goes through memory
2008-11-04 22:40 [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory jch at pps dot jussieu dot fr
@ 2008-11-04 22:49 ` pinskia at gcc dot gnu dot org
2008-11-05 0:29 ` jch at pps dot jussieu dot fr
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-04 22:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-11-04 22:48 -------
I think it depends on the tuning of the processor which decides if it should
goto memory or not. -mtune=generic makes it go through memory while
-mtune=core2 does not and we get:
movd %edi, %xmm0
paddd LC0(%rip), %xmm0
movd %xmm0, %eax
ret
Note I checking with -fPIC turned on.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38015
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/38015] Converting between int and vector using intrinsics goes through memory
2008-11-04 22:40 [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory jch at pps dot jussieu dot fr
2008-11-04 22:49 ` [Bug target/38015] " pinskia at gcc dot gnu dot org
@ 2008-11-05 0:29 ` jch at pps dot jussieu dot fr
2008-11-05 9:40 ` rguenth at gcc dot gnu dot org
2009-09-17 9:20 ` ubizjak at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: jch at pps dot jussieu dot fr @ 2008-11-05 0:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jch at pps dot jussieu dot fr 2008-11-05 00:27 -------
Then -mtune=generic is not doing something reasonable.
If I read correctly the docs I have available, going through memory doesn't win
on either Core2 or AMD family 10. It does win on the K8, but only in the
xmm->integer direction.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38015
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/38015] Converting between int and vector using intrinsics goes through memory
2008-11-04 22:40 [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory jch at pps dot jussieu dot fr
2008-11-04 22:49 ` [Bug target/38015] " pinskia at gcc dot gnu dot org
2008-11-05 0:29 ` jch at pps dot jussieu dot fr
@ 2008-11-05 9:40 ` rguenth at gcc dot gnu dot org
2009-09-17 9:20 ` ubizjak at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-05 9:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-11-05 09:38 -------
I think this was done on purpose.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38015
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/38015] Converting between int and vector using intrinsics goes through memory
2008-11-04 22:40 [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory jch at pps dot jussieu dot fr
` (2 preceding siblings ...)
2008-11-05 9:40 ` rguenth at gcc dot gnu dot org
@ 2009-09-17 9:20 ` ubizjak at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2009-09-17 9:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ubizjak at gmail dot com 2009-09-17 09:20 -------
(In reply to comment #3)
> I think this was done on purpose.
Yes, use -march=core2.
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38015
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-09-17 9:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 22:40 [Bug c/38015] New: Converting between int and vector using intrinsics goes through memory jch at pps dot jussieu dot fr
2008-11-04 22:49 ` [Bug target/38015] " pinskia at gcc dot gnu dot org
2008-11-05 0:29 ` jch at pps dot jussieu dot fr
2008-11-05 9:40 ` rguenth at gcc dot gnu dot org
2009-09-17 9:20 ` ubizjak at gmail dot com
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).