Re: [PATCH] MIPS: crypto: Clean up useless assignment operations

From: Maciej W. Rozycki
Date: Fri Jun 28 2024 - 12:43:21 EST


On Fri, 28 Jun 2024, WangYuli wrote:

> As you can see, regardless of the Clang or GCC version, this redundant
> operation affects the generated
>
> assembly code.

Boy, this code is horribly structured!

Anyway, rather than making it yet worse with another #ifdef I'd suggest
replacing both `while' loops with equivalent `for' ones with `len' being
the worker variable, which will then make the code structure a little bit
better and as a side effect address the missed optimisation automagically.

You might also consider Herbert's suggestion to use IS_ENABLED, however
in the current shape of code I find it kind of pointless anyway. Instead
I think that it would make more sense to factor out the block bodies to
small static inline helpers and then restructure the call sites so that
IS_ENABLED controls the loops, the conditionals, and the choice between
them as applicable.

Maciej