From c9ae4c70d4311c1d38534d0e10a4344c9dd5f848 Mon Sep 17 00:00:00 2001 From: Patrick Oppenlander Date: Fri, 17 Apr 2015 10:16:24 +1000 Subject: [PATCH] ppc32: fix fp_montgomery_reduce assembly Previous patch modified constraints from =m to =g. Turns out this also allows registers which doesn't work with the inline assembly instructions. If we change back to =m GCC 5.0 warns that constraints do not allow a register. In order to work around these issues we now pass the arguments in registers and let GCC handle the loading & storing. --- src/mont/fp_montgomery_reduce.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/mont/fp_montgomery_reduce.c b/src/mont/fp_montgomery_reduce.c index 4339252..ad074f9 100644 --- a/src/mont/fp_montgomery_reduce.c +++ b/src/mont/fp_montgomery_reduce.c @@ -325,22 +325,18 @@ asm( \ asm( \ " mullw 16,%3,%4 \n\t" \ " mulhwu 17,%3,%4 \n\t" \ - " addc 16,16,%0 \n\t" \ + " addc 16,16,%2 \n\t" \ " addze 17,17 \n\t" \ - " lwz 18,%1 \n\t" \ - " addc 16,16,18 \n\t" \ + " addc %1,16,%5 \n\t" \ " addze %0,17 \n\t" \ - " stw 16,%1 \n\t" \ -:"=r"(cy),"=g"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","cc"); ++tmpm; +:"=r"(cy),"=r"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "cc"); ++tmpm; #define PROPCARRY \ asm( \ - " lwz 16,%1 \n\t" \ - " addc 16,16,%0 \n\t" \ - " stw 16,%1 \n\t" \ - " xor %0,%0,%0 \n\t" \ - " addze %0,%0 \n\t" \ -:"=r"(cy),"=g"(_c[0]):"0"(cy),"1"(_c[0]):"16","cc"); + " addc %1,%3,%2 \n\t" \ + " xor %0,%2,%2 \n\t" \ + " addze %0,%2 \n\t" \ +:"=r"(cy),"=r"(_c[0]):"0"(cy),"1"(_c[0]):"cc"); /******************************************************************/ #elif defined(TFM_PPC64)