Subject: Re: [PATCH v3 4/5] powerpc/lib/sstep: Add prty instruction emulation

From: Segher Boessenkool <[email-masked]>
Date: Tue, 25 Jul 2017 10:30:33 -0500

On Tue, Jul 25, 2017 at 01:33:19PM +1000, Matt Brown wrote:
> +static nokprobe_inline void do_prty(struct pt_regs *regs, unsigned long v,
> +				int size, int ra)
> +{
> +	unsigned long long res = v;
> +
> +	res = (0x0001000100010001 & res) + (0x0001000100010001 & (res >> 8));
> +	res = (0x0000000700000007 & res) + (0x0000000700000007 & (res >> 16));
> +	if (size == 32) {		/* prtyw */
> +		regs->gpr[ra] = (0x0000000100000001 & res);
> +		return;
> +	}
> +
> +	res = (0x000000000000000f & res) + (0x000000000000000f & (res >> 32));
> +	regs->gpr[ra] = res & 1;	/*prtyd */
> +}

Does 7's and 0xf look strange (since the top bit in the values there
is always 0).  You always "and" the values with 1 later, you could do
that immediately (and change + to ^).

A general question about these patches: some things are inside #ifdef
__powerpc64__, some are not.  It seems it is the wrong macro, and it
should be used (or not used) consistently?

Segher