poly1305/asm/poly1305-x86_64.pl: add VPMADD52 code path.
[openssl.git] / crypto / poly1305 / asm / poly1305-x86.pl
index 01c3cbcda93f05aecc2a187b29ec3955b96fbd4c..9db38b5ecc4b60ce79462ad1a2c070ed50d47dd0 100755 (executable)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2016 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
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
 #
 # ====================================================================
 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
@@ -22,7 +29,9 @@
 # Westmere     4.58/+100%      1.43
 # Sandy Bridge 3.90/+100%      1.36
 # Haswell      3.88/+70%       1.18            0.72
+# Skylake      3.10/+60%       1.14            0.62
 # Silvermont   11.0/+40%       4.80
+# Goldmont     4.10/+200%      2.10
 # VIA Nano     6.71/+90%       2.47
 # Sledgehammer 3.51/+180%      4.27
 # Bulldozer    4.53/+140%      1.31
@@ -299,6 +308,7 @@ if ($sse2) {
        &adc    ("ebx",0);
        &adc    ("ecx",0);
        &adc    ("esi",0);
+       &adc    ("edi",0);
 
        &cmp    ("ebp",&wparam(2));             # done yet?
        &jne    (&label("loop"));
@@ -540,11 +550,12 @@ my $base = shift; $base = "esp" if (!defined($base));
 
 sub lazy_reduction {
 my $extra = shift;
-my $paddx = defined($extra) ? paddq : paddd;
 
        ################################################################
        # lazy reduction as discussed in "NEON crypto" by D.J. Bernstein
        # and P. Schwabe
+       #
+       # [(*) see discussion in poly1305-armv4 module]
 
         &movdqa        ($T0,$D3);
         &pand          ($D3,$MASK);
@@ -566,7 +577,7 @@ my $paddx = defined($extra) ? paddq : paddd;
                                                        # on Atom
         &psllq         ($T0,2);
        &paddq          ($T1,$D2);                      # h1 -> h2
-        &$paddx        ($T0,$D0);                      # h4 -> h0
+        &paddq         ($T0,$D0);                      # h4 -> h0 (*)
        &pand           ($D1,$MASK);
        &movdqa         ($D2,$T1);
        &psrlq          ($T1,26);
@@ -1166,11 +1177,12 @@ my $addr = shift;
        &shr    ("edi",2);
        &lea    ("ebp",&DWP(0,"edi","edi",4));  # *5
         &mov   ("edi",&wparam(1));             # output
-       add     ("eax","ebp");
+       &add    ("eax","ebp");
         &mov   ("ebp",&wparam(2));             # key
-       adc     ("ebx",0);
-       adc     ("ecx",0);
-       adc     ("edx",0);
+       &adc    ("ebx",0);
+       &adc    ("ecx",0);
+       &adc    ("edx",0);
+       &adc    ("esi",0);
 
        &movd   ($D0,"eax");                    # offload original hash value
        &add    ("eax",5);                      # compare to modulus