Use separate counters for 8-fold and single multiplication steps
Compilers are likely to generate shorter assembly for loops of the form `while( cnt-- ) { ... }` rather than `for( ; count >= X; count -= X ) { ... }`. (E.g. the latter needs a subtract+compare+branch after each loop, while the former only needs decrement+branch). Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
eacf3b9eb4
commit
63eb28c728
@ -1377,14 +1377,17 @@ mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *d, size_t d_len,
|
||||
mbedtls_mpi_uint c = 0; /* carry */
|
||||
size_t excess_len = d_len - s_len;
|
||||
|
||||
for( ; s_len >= 8; s_len -= 8 )
|
||||
size_t steps_x8 = s_len / 8;
|
||||
size_t steps_x1 = s_len & 7;
|
||||
|
||||
while( steps_x8-- )
|
||||
{
|
||||
MULADDC_X8_INIT
|
||||
MULADDC_X8_CORE
|
||||
MULADDC_X8_STOP
|
||||
}
|
||||
|
||||
for( ; s_len > 0; s_len-- )
|
||||
while( steps_x1-- )
|
||||
{
|
||||
MULADDC_X1_INIT
|
||||
MULADDC_X1_CORE
|
||||
|
Loading…
Reference in New Issue
Block a user