This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: PowerPC G5, 64-bit long long, bit counting and inline assembler...
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Gordon Royle <gordon at csse dot uwa dot edu dot au>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 10 Oct 2003 14:36:57 +0200
- Subject: Re: PowerPC G5, 64-bit long long, bit counting and inline assembler...
- References: <1065753147.30861.349.camel@ekaltadeta>
Gordon Royle <gordon@csse.uwa.edu.au> writes:
> I have a program that represents sets using the bit pattern in a 64-bit
> word, and I repeatedly have to answer the question "Does this word have
> exactly 2 bits set".
>
> Now I recently gained access to a Mac G5, with the 64-bit PowerPC G5
> chip, and so I naively expected a substantial increase in
> performance over my existing testing machine (in case it is relevant
> the chips are 2.667GHz Xeon vs 2GHz G5) because presumably gcc must
> "simulate" the 64-bit behaviour of "long long" on a 32-bit machine
> while it can do it natively on a G5.
>
> But in practice, I only gained about 20% - even when I did a test
> program that *only* did a few billion operations like &, |, ^ and the
> IF2BITS macro above....
Are you sure you used the right compiler switches to activate 64 bit
code generation? I don't know about powerpc, but usually you have to
give extra switches.
> Can I check that it *is* actually using the G5 in native 64-bit
> mode?
You could look at the assembly of, say, a+b with a and b long longs,
and see whether it is a single instruction.
> In addition, is there a faster way to check if a word has exactly
> 2-bits set? Would there be any gain from trying to inline assembler
> to do just this operation?
I don't think so. Powerpc does not have a population count intruction
(at least none is defined in its machine description in gcc).
--
Falk