This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Bit operations in g77
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: "Mortenson, Paul" <paul dot mortenson at evotecoai dot com>
- Cc: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 15 Apr 2002 23:49:55 +0200
- Subject: Re: Bit operations in g77
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <5FD8C12EECBBD4119DD10002B3027B9A010F570F@GABRIELLE>
"Mortenson, Paul" wrote:
> Is there an intrinsic function in g77 which performs the equivalent of
> "popcnt(x)", that is, a function which returns the number of bits set to "1"
> in the bit representation of an integer "x"??
Nope, unfortunately not.
> It is obviously possible to do this by using BTEST within a loop, but this
> seems likely to be awfully slow! If there isn't an intrinsic, is there a
> quicker way of doing this??
If it were an intrinsic, on architectures supporting a pop count
instruction, we could generate the instruction directly (like on Alpha).
Alas, you'll have to do with the loop over BTEST's.
Hope this helps,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)