Re: [PATCH net-next v5 06/20] zinc: ChaCha20 MIPS32r2 implementation

From: Paul Burton
Date: Tue Sep 18 2018 - 16:25:57 EST


Hi Jason,

On Tue, Sep 18, 2018 at 06:16:32PM +0200, Jason A. Donenfeld wrote:
> +.Lchacha20_mips_xor_aligned_4_b:
> + /* STORE_ALIGNED( 4, 0, $sp, 0+CONSTANT_OFS_SP) */
> + lw T0, 0+CONSTANT_OFS_SP($sp)
> + lw T1, 0(IN)
> + addu X0, T0
> + CPU_TO_LE32(X0)
> + xor X0, T1
> + .set noreorder
> + bne OUT, PTR_LAST_ROUND, .Loop_chacha20_rounds
> + sw X0, 0(OUT)
> + .set reorder
> +
> + .set noreorder
> + bne $at, BYTES, .Lchacha20_mips_xor_bytes
> + /* Empty delayslot, Increase NONCE_0, return NONCE_0 value */
> + addiu NONCE_0, 1
> + .set noreorder

Should this be .set reorder?

Even better - could we not just place the addiu before the bne & drop
the .set noreorder, allowing the assembler to fill the delay slot with
the addiu? Likewise in many other places throughout the patch.

That would be more future proof - particularly if we ever want to adjust
this for use with the nanoMIPS ISA which has no delay slots. It may also
allow the assembler the choice to use compact branches (ie. branches
without visible delay slots) when targeting MIPS32r6. I know neither of
these will currently build this code, but I think avoiding all the
noreorder blocks would be a nice cleanup just for the sake of
readability anyway.

Thanks,
Paul