bn: save/restore registers to/from stack
authorMartin Schwenke <martin@meltin.net>
Wed, 16 Jun 2021 06:54:26 +0000 (16:54 +1000)
committerPauli <pauli@openssl.org>
Tue, 22 Jun 2021 08:30:17 +0000 (18:30 +1000)
mtvsrd/mfvsrd are ISA >= 2.07 only, so this won't work for older
CPUs.

It would be possible to use this scheme only in the ISA >= 3.0
implementation.  However, in the future it may be possible for newer
ISAs to allow CPU implementations without a vector unit, so don't
bother.  The performance improvement versus using the stack was small
anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15798)

crypto/bn/asm/ppc64-mont-fixed.pl

index bb4290182dbb48e593747a1c287bb91236fb434b..da4967a730f7b92f91bbc11dd90a9edd0851d9b8 100755 (executable)
@@ -345,12 +345,12 @@ sub save_registers($)
        my $n = $self->{n};
 
        $self->add_code(<<___);
-       mtvsrd  $vsrs[0],$lo
+       std     $lo,-8($sp)
 ___
 
        for (my $j = 0; $j <= $n+1; $j++) {
                $self->{code}.=<<___;
-       mtvsrd  $vsrs[$j+1],$tp[$j]
+       std     $tp[$j],-`($j+2)*8`($sp)
 ___
        }
 
@@ -366,12 +366,12 @@ sub restore_registers($)
        my $n = $self->{n};
 
        $self->add_code(<<___);
-       mfvsrd  $lo,$vsrs[0]
+       ld      $lo,-8($sp)
 ___
 
        for (my $j = 0; $j <= $n+1; $j++) {
                $self->{code}.=<<___;
-       mfvsrd  $tp[$j],$vsrs[$j+1]
+       ld      $tp[$j],-`($j+2)*8`($sp)
 ___
        }