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

Re: Bit operations in g77


"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)


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