Skip to content

Commit

Permalink
Merge pull request #4968 from davidhorstmann-arm/fix-aarch64-asm-cons…
Browse files Browse the repository at this point in the history
…traints

Fix aarch64 assembly for bignum multiplication
  • Loading branch information
gilles-peskine-arm authored Sep 27, 2021
2 parents 27f84fc + 7500a0e commit aafb21f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 0 additions & 4 deletions ChangeLog.d/muladdc-amd64-memory.txt

This file was deleted.

5 changes: 5 additions & 0 deletions ChangeLog.d/muladdc-memory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix
* Fix missing constraints on x86_64 and aarch64 assembly code
for bignum multiplication that broke some bignum operations with
(at least) Clang 12.
Fixes #4116, #4786, #4917, #4962.
14 changes: 7 additions & 7 deletions library/bn_mul.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"adcq %%rdx, %%rcx\n" \
"addq $8, %%rdi\n"

#define MULADDC_STOP \
#define MULADDC_STOP \
: "+c" (c), "+D" (d), "+S" (s), "+m" (*(uint64_t (*)[16]) d) \
: "b" (b), "m" (*(const uint64_t (*)[16]) s) \
: "rax", "rdx", "r8" \
Expand All @@ -240,18 +240,18 @@
#define MULADDC_CORE \
"ldr x4, [%2], #8 \n\t" \
"ldr x5, [%1] \n\t" \
"mul x6, x4, %3 \n\t" \
"umulh x7, x4, %3 \n\t" \
"mul x6, x4, %4 \n\t" \
"umulh x7, x4, %4 \n\t" \
"adds x5, x5, x6 \n\t" \
"adc x7, x7, xzr \n\t" \
"adds x5, x5, %0 \n\t" \
"adc %0, x7, xzr \n\t" \
"str x5, [%1], #8 \n\t"

#define MULADDC_STOP \
: "+r" (c), "+r" (d), "+r" (s) \
: "r" (b) \
: "x4", "x5", "x6", "x7", "cc" \
#define MULADDC_STOP \
: "+r" (c), "+r" (d), "+r" (s), "+m" (*(uint64_t (*)[16]) d) \
: "r" (b), "m" (*(const uint64_t (*)[16]) s) \
: "x4", "x5", "x6", "x7", "cc" \
);

#endif /* Aarch64 */
Expand Down

0 comments on commit aafb21f

Please sign in to comment.