[PATCH v2 2/5] powerpc/lib/sstep: Add popcnt instruction emulation

Segher Boessenkool segher at kernel.crashing.org
Mon Jul 24 17:36:55 AEST 2017


Hi Matt,

On Mon, Jul 24, 2017 at 11:01:06AM +1000, Matt Brown wrote:
> +	for (i = 0; i < (64 / size); i++) {

If you do

  for (i = 0; i < 64; i += size)

things are slightly nicer.

> +		if ((i * size) < 32)
> +			low |= n << (i * size);
> +		else
> +			high |= n << ((i * size) - 32);
> +	}
> +	regs->gpr[ra] = (high << 32) | low;

Why have separate high and low vars?

And there are much better ways to calculate popcount, of course.


Segher


More information about the Linuxppc-dev mailing list