This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [i386] Replace builtins with vector extensions
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 Apr 2013 11:08:38 +0200 (CEST)
- Subject: Re: [i386] Replace builtins with vector extensions
- References: <alpine dot DEB dot 2 dot 02 dot 1304071030320 dot 4934 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 02 dot 1304082243070 dot 3872 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc1iONVnTjKJ1gfqtP7Yyf+7PSYb4ZoCUbdVkks1k7tYfg at mail dot gmail dot com>
On Tue, 9 Apr 2013, Richard Biener wrote:
On Mon, Apr 8, 2013 at 10:47 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
On Sun, 7 Apr 2013, Marc Glisse wrote:
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_slli_epi16 (__m128i __A, int __B)
{
- return (__m128i)__builtin_ia32_psllwi128 ((__v8hi)__A, __B);
+ return (__m128i) ((__v8hi)__A << __B);
}
Actually, I believe I have to keep using the builtins for shifts, because
the intrinsics have well defined behavior for large __B whereas << and >>
don't.
I seem to remember discussion in the PR(s) that the intrinsics should
(and do for other compilers) expand to the desired instructions even when
the corresponding instruction set is disabled.
emmintrin.h starts with:
#ifndef __SSE2__
# error "SSE2 instruction set not enabled"
The closest thing I can think of is issues with -mfpmath=387, but that
shouldn't matter for full vector ops.
Using vector extension
makes that harder to achieve. Other than that I am all for using the
vector extensions, but I think you need carefully wrapped __extension__
markers so that with -std=c89 -pedantic you still can compile programs
using the intrinsics?
The *intrin.h files already use __extension__ to create vectors, like:
return __extension__ (__m128d){ __F, 0.0 };
but even when I remove it it does not warn with -std=c89 -pedantic.
--
Marc Glisse