Skip to content

Commit 0cc62f9

Browse files
Hanno BeckerKurt Godwin
authored andcommitted
Remove explicit width suffixes from Arm bignum assembly
Within the M-profile of the Arm architecture, some instructions admit both a 16-bit and a 32-bit encoding. For those instructions, some assemblers support the use of the .n (narrow) and .w (wide) suffixes to force a choice of instruction encoding width. Forcing the size of encodings may be useful to ensure alignment of code, which can have a significant performance impact on some microarchitectures. It is for this reason that a previous commit introduced explicit .w suffixes into what was believed to be M-profile only assembly in library/bn_mul.h. This change, however, introduced two issues: - First, the assembly block in question is used also for Armv7-A systems, on which the .n/.w distinction is not meaningful (all instructions are 32-bit). - Second, compiler support for .n/.w suffixes appears patchy, leading to compilation failures even when building for M-profile targets. This commit removes the .w annotations in order to restore working code, deferring controlled re-introduction for the sake of performance. Fixes Mbed-TLS#6089. Signed-off-by: Hanno Becker <hanno.becker@arm.com>
1 parent 869298b commit 0cc62f9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

library/bn_mul.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -717,10 +717,10 @@
717717

718718
#define MULADDC_X1_CORE \
719719
".p2align 2 \n\t" \
720-
"ldr.w %[a], [%[in]], #4 \n\t" \
721-
"ldr.w %[b], [%[acc]] \n\t" \
720+
"ldr %[a], [%[in]], #4 \n\t" \
721+
"ldr %[b], [%[acc]] \n\t" \
722722
"umaal %[b], %[carry], %[scalar], %[a] \n\t" \
723-
"str.w %[b], [%[acc]], #4 \n\t"
723+
"str %[b], [%[acc]], #4 \n\t"
724724

725725
#define MULADDC_X1_STOP \
726726
: [a] "=&r" (tmp_a), \
@@ -751,14 +751,14 @@
751751
* 2 cycles, while subsequent loads/stores are single-cycle. */
752752
#define MULADDC_X2_CORE \
753753
".p2align 2 \n\t" \
754-
"ldr.w %[a0], [%[in]], #+8 \n\t" \
755-
"ldr.w %[b0], [%[acc]], #+8 \n\t" \
756-
"ldr.w %[a1], [%[in], #-4] \n\t" \
757-
"ldr.w %[b1], [%[acc], #-4] \n\t" \
754+
"ldr %[a0], [%[in]], #+8 \n\t" \
755+
"ldr %[b0], [%[acc]], #+8 \n\t" \
756+
"ldr %[a1], [%[in], #-4] \n\t" \
757+
"ldr %[b1], [%[acc], #-4] \n\t" \
758758
"umaal %[b0], %[carry], %[scalar], %[a0] \n\t" \
759759
"umaal %[b1], %[carry], %[scalar], %[a1] \n\t" \
760-
"str.w %[b0], [%[acc], #-8] \n\t" \
761-
"str.w %[b1], [%[acc], #-4] \n\t"
760+
"str %[b0], [%[acc], #-8] \n\t" \
761+
"str %[b1], [%[acc], #-4] \n\t"
762762

763763
#define MULADDC_X2_STOP \
764764
: [a0] "=&r" (tmp_a0), \

0 commit comments

Comments
 (0)