libgcrypt-1.9.2: cipher/poly1305.c does not compile on i686/32 with gcc-4.7.3 ( --disable-asm does not work)

Jussi Kivilinna jussi.kivilinna at iki.fi
Wed Mar 3 18:08:08 CET 2021


On 2.3.2021 1.02, horst.wente--- via Gcrypt-devel wrote:
> Hello!
> 
> The "#define ADD_1305_32" ( for "defined (__i386__) && __GNUC__ >= 4" ) leads to
> 
>> poly1305.c: In function 'poly1305_blocks':
>> poly1305.c:424:7: error: can't find a register in class 'GENERAL_REGS' while
>      reloading 'asm'
>> poly1305.c:424:7: error: 'asm' operand has impossible constraints
> 
> I suppose the template uses too many registers, so I redefined it and it seems to
> work for me ( all tests successful ).
> 

Thanks for reporting. I think it is better to just disable this macro for GCC-4.x
as any changes to asm operand types cause performance drop with newer GCC.
When ADD_1305_32 is not provided specific arch, generic version is used.

-Jussi

> hth
> horst wente
> 
> 
> --- cipher/poly1305.c.orig      2021-01-28 13:53:52.000000000 +0100
> +++ cipher/poly1305.c   2021-03-01 20:25:26.000000000 +0100
> @@ -314,14 +314,19 @@
> 
>   /* A += B (i386) */
>   #define ADD_1305_32(A4, A3, A2, A1, A0, B4, B3, B2, B1, B0) \
> -      __asm__ ("addl %5, %0\n" \
> -              "adcl %6, %1\n" \
> -              "adcl %7, %2\n" \
> -              "adcl %8, %3\n" \
> -              "adcl %9, %4\n" \
> -              : "+r" (A0), "+r" (A1), "+r" (A2), "+r" (A3), "+r" (A4) \
> -              : "g" (B0), "g" (B1), "g" (B2), "g" (B3), "g" (B4) \
> -              : "cc" )
> +      __asm__ ("clc\n"         \
> +               "addl %5, %0\n" \
> +               "movl %6, %5\n" \
> +               "adcl %5, %1\n" \
> +               "movl %7, %5\n" \
> +               "adcl %5, %2\n" \
> +               "movl %8, %5\n" \
> +               "adcl %5, %3\n" \
> +               "movl %9, %5\n" \
> +               "adcl %5, %4\n" \
> +               : "+m" (A0), "+m" (A1), "+m" (A2), "+m" (A3), "+m" (A4) \
> +               : "r" (B0), "g" (B1), "g" (B2), "g" (B3), "g" (B4) \
> +               : "cc" )
> 
>   #endif /* __i386__ */
> 
> 
> _______________________________________________
> Gcrypt-devel mailing list
> Gcrypt-devel at gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
> 




More information about the Gcrypt-devel mailing list