[Skiboot] [PATCH v2 05/11] libflash/ecc: Remove hand rolled parity asm

Joel Stanley joel at jms.id.au
Fri May 4 12:10:30 AEST 2018


We get the same code generation using the builtin:

GCC 7.3:

   a3584:       7d 29 00 f4     popcntb r9,r9
   a3588:       7d 29 01 74     prtyd   r9,r9

GCC 6.3:

   a0bfc:       7d 29 00 f4     popcntb r9,r9
   a0c00:       7d 29 01 74     prtyd   r9,r9

Clang 7 (and clang 6):

   bd48c:       7c e7 03 f4     popcntd r7,r7
   bd490:       54 e7 07 fe     clrlwi  r7,r7,31

(Not sure why the clang builtin generates different code)

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 libflash/ecc.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/libflash/ecc.c b/libflash/ecc.c
index cfb1a1364bce..9ed9015afa4f 100644
--- a/libflash/ecc.c
+++ b/libflash/ecc.c
@@ -110,22 +110,6 @@ static enum eccbitfields syndromematrix[] = {
         UE, UE, UE, UE,  4, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE,
 };
 
-static uint8_t parity(uint64_t data)
-{
-#ifdef __SKIBOOT__
-	uint8_t p;
-
-	asm volatile(
-		"popcntb %1,%0\n"
-		"prtyd   %1,%1\n"
-		: "=r"(p) : "r"(data));
-
-	return p;
-#else
-	return __builtin_parityll(data);
-#endif
-}
-
 /**
  * Create the ECC field corresponding to a 8-byte data field
  *
@@ -138,7 +122,7 @@ static uint8_t eccgenerate(uint64_t data)
 	uint8_t result = 0;
 
 	for (i = 0; i < 8; i++)
-		result |= parity(eccmatrix[i] & data) << i;
+		result |= __builtin_parityll(eccmatrix[i] & data) << i;
 
 	return result;
 }
-- 
2.17.0



More information about the Skiboot mailing list