[openssl-dev] [openssl.org #4162] [PATCH] Removing vrsave load and store

Leonidas Da Silva Barbosa via RT rt at openssl.org
Mon Nov 30 18:37:02 UTC 2015


Access to VRSAVE have a high cost in performance.
Since ABI was update we don't need to save what
vector register we are using. Removing VRSAVE access
can improve a bit more our performance.

Signed-off-by: Leonidas S. Barbosa <leosilva at linux.vnet.ibm.com>
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo at linux.vnet.ibm.com>
---
 crypto/aes/asm/aesp8-ppc.pl     | 20 --------------------
 crypto/modes/asm/ghashp8-ppc.pl | 11 -----------
 2 files changed, 31 deletions(-)

diff --git a/crypto/aes/asm/aesp8-ppc.pl b/crypto/aes/asm/aesp8-ppc.pl
index a1891cc..35f36ef 100755
--- a/crypto/aes/asm/aesp8-ppc.pl
+++ b/crypto/aes/asm/aesp8-ppc.pl
@@ -104,10 +104,6 @@ Lset_encrypt_key:
 	andi.		r0,$bits,0x3f
 	bne-		Lenc_key_abort
 
-	lis		r0,0xfff0
-	mfspr		$vrsave,256
-	mtspr		256,r0
-
 	bl		Lconsts
 	mtlr		r11
 
@@ -336,7 +332,6 @@ Ldone:
 	vsel		$in1,$outhead,$in1,$outmask
 	stvx		$in1,0,$inp
 	li		$ptr,0
-	mtspr		256,$vrsave
 	stw		$rounds,0($out)
 
 Lenc_key_abort:
@@ -408,10 +403,7 @@ $code.=<<___;
 .align	5
 .${prefix}_${dir}crypt:
 	lwz		$rounds,240($key)
-	lis		r0,0xfc00
-	mfspr		$vrsave,256
 	li		$idx,15			# 15 is not typo
-	mtspr		256,r0
 
 	lvx		v0,0,$inp
 	neg		r11,$out
@@ -465,7 +457,6 @@ Loop_${dir}c:
 	vsel		v0,v0,v4,v2
 	stvx		v0,$idx,$out
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,3,0
@@ -490,9 +481,6 @@ $code.=<<___;
 	bltlr-
 
 	cmpwi		$enc,0			# test direction
-	lis		r0,0xffe0
-	mfspr		$vrsave,256
-	mtspr		256,r0
 
 	li		$idx,15
 	vxor		$rndkey0,$rndkey0,$rndkey0
@@ -638,7 +626,6 @@ Lcbc_done:
 	vsel		$inout,$ivec,$inptail,$outmask
 	stvx		$inout,$idx,$ivp
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,6,0
@@ -1196,7 +1183,6 @@ Lcbc_dec8x_done:
 	stvx		$inpperm,r11,$sp
 	addi		r11,r11,32
 
-	mtspr		256,$vrsave
 	lvx		v20,r10,$sp		# ABI says so
 	addi		r10,r10,32
 	lvx		v21,r11,$sp
@@ -1249,10 +1235,6 @@ $code.=<<___;
 	${UCMP}i	$len,1
 	bltlr-
 
-	lis		r0,0xfff0
-	mfspr		$vrsave,256
-	mtspr		256,r0
-
 	li		$idx,15
 	vxor		$rndkey0,$rndkey0,$rndkey0
 	le?vspltisb	$tmp,0x0f
@@ -1344,7 +1326,6 @@ Loop_ctr32_enc:
 	vsel		$inout,$outhead,$inout,$outmask
 	stvx		$inout,0,$out
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,6,0
@@ -1849,7 +1830,6 @@ Lctr32_enc8x_done:
 	stvx		$inpperm,r11,$sp
 	addi		r11,r11,32
 
-	mtspr		256,$vrsave
 	lvx		v20,r10,$sp		# ABI says so
 	addi		r10,r10,32
 	lvx		v21,r11,$sp
diff --git a/crypto/modes/asm/ghashp8-ppc.pl b/crypto/modes/asm/ghashp8-ppc.pl
index e76a58c..63e46fa 100755
--- a/crypto/modes/asm/ghashp8-ppc.pl
+++ b/crypto/modes/asm/ghashp8-ppc.pl
@@ -46,7 +46,6 @@ my ($Xip,$Htbl,$inp,$len)=map("r$_",(3..6));	# argument block
 
 my ($Xl,$Xm,$Xh,$IN)=map("v$_",(0..3));
 my ($zero,$t0,$t1,$t2,$xC2,$H,$Hh,$Hl,$lemask)=map("v$_",(4..12));
-my $vrsave="r12";
 
 $code=<<___;
 .machine	"any"
@@ -56,11 +55,8 @@ $code=<<___;
 .globl	.gcm_init_p8
 .align	5
 .gcm_init_p8:
-	lis		r0,0xfff0
 	li		r8,0x10
-	mfspr		$vrsave,256
 	li		r9,0x20
-	mtspr		256,r0
 	li		r10,0x30
 	lvx_u		$H,0,r4			# load H
 
@@ -90,7 +86,6 @@ $code=<<___;
 	stvx_u		$H, r9,r3
 	stvx_u		$Hh,r10,r3
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,2,0
@@ -102,9 +97,7 @@ $code=<<___;
 .gcm_gmult_p8:
 	lis		r0,0xfff8
 	li		r8,0x10
-	mfspr		$vrsave,256
 	li		r9,0x20
-	mtspr		256,r0
 	li		r10,0x30
 	lvx_u		$IN,0,$Xip		# load Xi
 
@@ -140,7 +133,6 @@ $code=<<___;
 	le?vperm	$Xl,$Xl,$Xl,$lemask
 	stvx_u		$Xl,0,$Xip		# write out Xi
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,2,0
@@ -152,9 +144,7 @@ $code=<<___;
 .gcm_ghash_p8:
 	lis		r0,0xfff8
 	li		r8,0x10
-	mfspr		$vrsave,256
 	li		r9,0x20
-	mtspr		256,r0
 	li		r10,0x30
 	lvx_u		$Xl,0,$Xip		# load Xi
 
@@ -209,7 +199,6 @@ Loop:
 	le?vperm	$Xl,$Xl,$Xl,$lemask
 	stvx_u		$Xl,0,$Xip		# write out Xi
 
-	mtspr		256,$vrsave
 	blr
 	.long		0
 	.byte		0,12,0x14,0,0,0,4,0
-- 
2.5.0

_______________________________________________
openssl-bugs-mod mailing list
openssl-bugs-mod at openssl.org
https://mta.openssl.org/mailman/listinfo/openssl-bugs-mod



More information about the openssl-dev mailing list