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

From: Segher Boessenkool <[email-masked]>
Date: Mon, 24 Jul 2017 02:36:55 -0500

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