This is the mail archive of the gcc-patches@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]

[PATCH, i386] Committed: Fix PR target/32961: Gcc has different requirements for x86 shift xmm intrinsics


Hello!

As confirmed in PR trail, there is no requirement that
_mm_slli_epi32() and friends operate only with immediate shift counts.
Attached patch fixes this problem.

Following testcase:

--cut here--
#include <xmmintrin.h>
__m128i a;

void x (char n)
{
  a = _mm_slli_epi32 (a, n);
}
--cut here--

compiles into:

x:
        subl    $4, %esp
        movsbl  8(%esp),%eax
        movdqa  a, %xmm0
        movl    %eax, (%esp)
        movd    (%esp), %xmm1
        pslld   %xmm1, %xmm0
        movdqa  %xmm0, a
        addl    $4, %esp
        ret

(BTW: TARGET_INTER_UNIT_MOVES moves directly from %eax to %xmm1).

We still generate pslld $N for immediate arguments to _mm_slli_epi32():

x:
        movdqa  a, %xmm0
        pslld   $5, %xmm0
        movdqa  %xmm0, a
        ret

and for immediates that doesn't fit imm8:

x:
        movdqa  a, %xmm0
        movd    .LC0, %xmm1
        pslld   %xmm1, %xmm0
        movdqa  %xmm0, a
        ret

The patch was bootstrapped and regression tested on i686-pc-linux-gnu.
Pathc is commited to mainline and will be ported to 4.2 after a couple
of days.

2007-10-17  Uros Bizjak  <ubizjak@gmail.com>

	PR target/32961
	* config/i386/i386.c (ix86_expand_builtin) [IX86_BUILTIN_PSLLWI128,
	IX86_BUILTIN_PSLLDI128, BUILTIN_PSLLQI128, IX86_BUILTIN_PSRAWI128,
	IX86_BUILTIN_PSRADI128, IX86_BUILTIN_PSRLWI128,
	IX86_BUILTIN_PSRLDI128, IX86_BUILTIN_PSRLQI128]: Do not require
	immediate shift value.
	config/i386/emmintrin.h (_mm_slli_epi16, _mm_slli_epi32,
	_mm_slli_epi64, _mm_srai_epi16, _mm_srai_epi32, _mm_srli_epi16,
	_mm_srli_epi32, _mm_srli_epi64): Remove 'const' from count argument.
	Remove macros for !__OPTIMIZE__ case.

testsuite/ChangeLog:

2007-10-17  Uros Bizjak  <ubizjak@gmail.com>

	PR target/32961
	* gcc.target/i386/pr32961.c: New testcase.
	* gcc.target/i386/sse-13.c: Remove __builtin_ia32_psllwi128,
	__builtin_ia32_psrlqi128, __builtin_ia32_psrlwi128,
	__builtin_ia32_psrldi128, __builtin_ia32_psrawi128,
	__builtin_ia32_psradi128, __builtin_ia32_psllqi128 and
	__builtin_ia32_pslldi128 defines.

Uros.

Attachment: pr32961.diff
Description: Binary data


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