Update copyright year
[openssl.git] / crypto / bn / asm / x86_64-mont5.pl
index 7ed22326bde907461de727a4fb1f2ab93c24ab07..f43e13d11643a58fde41a069b400bf4b010c09a2 100755 (executable)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2011-2019 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the OpenSSL license (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -120,7 +120,7 @@ $code.=<<___;
        push    %r14
 .cfi_push      %r14
        push    %r15
-.cfi_push      %r14
+.cfi_push      %r15
 
        neg     $num
        mov     %rsp,%r11
@@ -419,22 +419,23 @@ $code.=<<___;
        mov     %rax,($rp,$i,8)         # rp[i]=tp[i]-np[i]
        mov     8($ap,$i,8),%rax        # tp[i+1]
        lea     1($i),$i                # i++
-       dec     $j                      # doesnn't affect CF!
+       dec     $j                      # doesn't affect CF!
        jnz     .Lsub
 
        sbb     \$0,%rax                # handle upmost overflow bit
+       mov     \$-1,%rbx
+       xor     %rax,%rbx
        xor     $i,$i
-       and     %rax,$ap
-       not     %rax
-       mov     $rp,$np
-       and     %rax,$np
        mov     $num,$j                 # j=num
-       or      $np,$ap                 # ap=borrow?tp:rp
-.align 16
-.Lcopy:                                        # copy or in-place refresh
-       mov     ($ap,$i,8),%rax
+
+.Lcopy:                                        # conditional copy
+       mov     ($rp,$i,8),%rcx
+       mov     (%rsp,$i,8),%rdx
+       and     %rbx,%rcx
+       and     %rax,%rdx
        mov     $i,(%rsp,$i,8)          # zap temporary vector
-       mov     %rax,($rp,$i,8)         # rp[i]=tp[i]
+       or      %rcx,%rdx
+       mov     %rdx,($rp,$i,8)         # rp[i]=tp[i]
        lea     1($i),$i
        sub     \$1,$j
        jnz     .Lcopy
@@ -2421,7 +2422,7 @@ my $N=$STRIDE/4;          # should match cache line size
 $code.=<<___;
        movdqa  0(%rax),%xmm0           # 00000001000000010000000000000000
        movdqa  16(%rax),%xmm1          # 00000002000000020000000200000002
-       lea     88-112(%rsp,%r10),%r10  # place the mask after tp[num+1] (+ICache optimizaton)
+       lea     88-112(%rsp,%r10),%r10  # place the mask after tp[num+1] (+ICache optimization)
        lea     128($bp),$bptr          # size optimization
 
        pshufd  \$0,%xmm5,%xmm5         # broadcast index
@@ -2909,6 +2910,7 @@ bn_powerx5:
 .align 32
 bn_sqrx8x_internal:
 __bn_sqrx8x_internal:
+.cfi_startproc
        ##################################################################
        # Squaring part:
        #
@@ -3206,11 +3208,19 @@ $code.=<<___;
 
 .align 32
 .Lsqrx8x_break:
-       sub     16+8(%rsp),%r8          # consume last carry
+       xor     $zero,$zero
+       sub     16+8(%rsp),%rbx         # mov 16(%rsp),%cf
+       adcx    $zero,%r8
        mov     24+8(%rsp),$carry       # initial $tptr, borrow $carry
+       adcx    $zero,%r9
        mov     0*8($aptr),%rdx         # a[8], modulo-scheduled
-       xor     %ebp,%ebp               # xor   $zero,$zero
+       adc     \$0,%r10
        mov     %r8,0*8($tptr)
+       adc     \$0,%r11
+       adc     \$0,%r12
+       adc     \$0,%r13
+       adc     \$0,%r14
+       adc     \$0,%r15
        cmp     $carry,$tptr            # cf=0, of=0
        je      .Lsqrx8x_outer_loop
 
@@ -3533,6 +3543,7 @@ __bn_sqrx8x_reduction:
        cmp     8+8(%rsp),%r8           # end of t[]?
        jb      .Lsqrx8x_reduction_loop
        ret
+.cfi_endproc
 .size  bn_sqrx8x_internal,.-bn_sqrx8x_internal
 ___
 }\f