[fortran, patch] Implement POPCNT and POPPAR

FX fxcoudert@gmail.com
Tue Aug 31 13:18:00 GMT 2010


> Hm, why you don't also use __buitlin_parity and friends?

Because I didn't know they existed! And I see that it leads to much better generated code that way, at least on x86_64, where popcount apparently expands to a libgcc call while parity does not. Thanks Uros!

Please find amended patch using both popcount{,l,ll} and parity{,l,ll} built-ins to implement the POPCNT and POPPAR Fortran intrinsics. For types larger than "long long", we call the long long variant twice on two 64-bit parts of the integer, and add (for popcount) or xor (for parity) the results.

Also, this updated patch includes documentation of the intrinsics, which I forgot in last version.

Bootstrapped and regtested on x86_64-linux, OK to commit?

FX


PS for Tobias: I did look at implementing a int128 libgcc intrinsic and use it, but it's much much more work than emitting the code directly... so I did not go that route, sorry!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: popcnt_poppar_2.ChangeLog
Type: application/octet-stream
Size: 601 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100831/81afa593/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: popcnt_poppar_2.diff
Type: application/octet-stream
Size: 16735 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100831/81afa593/attachment-0001.obj>


More information about the Gcc-patches mailing list