-#!/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
#
# June 2015
#
-# ~6.4/2.2 cpb on z10/z196+, >2x improvement over compiler-generated
+# ~6.6/2.3 cpb on z10/z196+, >2x improvement over compiler-generated
# code. For older compiler improvement coefficient is >3x, because
# then base 2^64 and base 2^32 implementations are compared.
#
.type poly1305_blocks,\@function
.align 16
poly1305_blocks:
- srl${g} $len,$len,4
+ srl${g} $len,4 # fixed-up in 64-bit build
lghi %r0,0
cl${g}r $len,%r0
je .Lno_data
stm${g} %r6,%r14,`6*$SIZE_T`($sp)
+ llgfr $padbit,$padbit # clear upper half, much needed with
+ # non-64-bit ABI
lg $r0,32($ctx) # load key
lg $r1,40($ctx)
ngr $h0,$h2
srlg $t0,$h2,2
algr $h0,$t0
+ lghi $t1,3
+ ngr $h2,$t1
algr $h0,$d0lo
- lghi $t1,3
alcgr $h1,$d1hi # $d1hi is still zero
- ngr $h2,$t1
+ alcgr $h2,$d1hi # $d1hi is still zero
brct$g $len,.Loop
}
$code =~ s/\`([^\`]*)\`/eval $1/gem;
+$code =~ s/\b(srlg\s+)(%r[0-9]+\s*,)\s*([0-9]+)/$1$2$2$3/gm;
print $code;
close STDOUT;