[patch] Move the popcnt intrinsics to a separate file

Sebastian Pop sebpop@gmail.com
Tue Dec 1 05:49:00 GMT 2009


On Mon, Nov 30, 2009 at 15:53, Richard Henderson <rth@redhat.com> wrote:
> On 11/30/2009 09:44 AM, Sebastian Pop wrote:
>>>
>>> But GCC has fallback implementations in libgcc.
>>>
>>
>> Could you point me to which file implements these fallbacks?  I cannot
>> find it with grep.
>
> gcc/libgcc2.c, of course.
>
>> An alternative to this patch would be to define the _mm_popcnt_u32 and
>> _mm_popcnt_u64 intrinsics in abmintrin.h.  Would that be acceptable?
>
> Yes.
>

Attached is a patch that does that.  I have split the patch in two parts:
one that adds the ABM intrinsics file,

	 * config/i386/abmintrin.h: New.
	 * config/i386/i386-c.c (ix86_target_macros_internal): Defined __ABM__.
	 * config/i386/x86intrin.h: Include abmintrin.h when __ABM__ is defined.

the other one adds the _mm_popcnt_u64 and _mm_popcnt_u32 intrinsics:

	* config/i386/abmintrin.h (_mm_popcnt_u32): New.
	(_mm_popcnt_u64): New.

Also attached is a patch that adds intrinsics for the lzcount insns:

	* config/i386/abmintrin.h (__lzcnt16): New.
	(__lzcnt): New.
	(__lzcnt64): New.
	* config/i386/i386-builtin-types.def (UINT16_FTYPE_UINT16): New.
	(UINT_FTYPE_UINT): New.
	(UINT64_FTYPE_UINT64): New.
	* config/i386/i386.c (IX86_BUILTIN_LZCNT16): New.
	(IX86_BUILTIN_LZCNT32): New.
	(IX86_BUILTIN_LZCNT64): New.
	(bdesc_special_args): Add __builtin_lzcnt16, __builtin_lzcnt32,
	and __builtin_lzcnt64.
	(ix86_expand_args_builtin): Handle UINT16_FTYPE_UINT16,
	UINT_FTYPE_UINT, and UINT64_FTYPE_UINT64.

Testing in progress on amd64-linux.  Ok for trunk if this passes?

Thanks,
Sebastian Pop
--
AMD / Open Source Compiler Engineering / GNU Tools
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ABM-intrinsics-file.patch
Type: text/x-diff
Size: 3050 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091201/05472205/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lzcount-intrinsics.patch
Type: text/x-diff
Size: 3917 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091201/05472205/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-ABM-popcount-intrinsics.patch
Type: text/x-diff
Size: 1074 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091201/05472205/attachment-0002.bin>


More information about the Gcc-patches mailing list