Gordon Royle <gordon@xxxxxxxxxxxxxxx> 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