[PATCH] powerpc: cmp -> cmpd for 64-bit

Michael Ellerman mpe at ellerman.id.au
Wed Oct 12 14:05:19 AEDT 2016


Segher Boessenkool <segher at kernel.crashing.org> writes:

> PowerPC's "cmp" instruction has four operands.  Normally people write
> "cmpw" or "cmpd" for the second cmp operand 0 or 1.  But, frequently
> people forget, and write "cmp" with just three operands.
>
> With older binutils this is silently accepted as if this was "cmpw",
> while often "cmpd" is wanted.  With newer binutils GAS will complain
> about this for 64-bit code.  For 32-bit code it still silently assumes
> "cmpw" is what is meant.

Thanks.

Anton already sent a fix for the two vdso ones, which were real bugs,
and that's now in Linus' tree.

> diff --git a/arch/powerpc/include/asm/cpuidle.h b/arch/powerpc/include/asm/cpuidle.h
> index 01b8a13..3919332 100644
> --- a/arch/powerpc/include/asm/cpuidle.h
> +++ b/arch/powerpc/include/asm/cpuidle.h
> @@ -26,7 +26,7 @@ extern u64 pnv_first_deep_stop_state;

#define	IDLE_STATE_ENTER_SEQ(IDLE_INST)				\
	/* Magic NAP/SLEEP/WINKLE mode enter sequence */	\
>  	std	r0,0(r1);					\
>  	ptesync;						\
>  	ld	r0,0(r1);					\
> -1:	cmp	cr0,r0,r0;					\
> +1:	cmpd	cr0,r0,r0;					\
>  	bne	1b;						\
>  	IDLE_INST;						\
>  	b	.

What's this one doing, is it a bug? I can't really tell without knowing
what the magic sequence is meant to do.

Mahesh, Vaidy?

cheers


More information about the Linuxppc-dev mailing list