Skip to content

Commit 1fdca4a

Browse files
shenkistewartsmith
authored andcommitted
libflash/ecc: Remove hand rolled parity asm
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 <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent 4640e70 commit 1fdca4a

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

libflash/ecc.c

+1-17
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,6 @@ static enum eccbitfields syndromematrix[] = {
110110
UE, UE, UE, UE, 4, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE,
111111
};
112112

113-
static uint8_t parity(uint64_t data)
114-
{
115-
#ifdef __SKIBOOT__
116-
uint8_t p;
117-
118-
asm volatile(
119-
"popcntb %1,%0\n"
120-
"prtyd %1,%1\n"
121-
: "=r"(p) : "r"(data));
122-
123-
return p;
124-
#else
125-
return __builtin_parityll(data);
126-
#endif
127-
}
128-
129113
/**
130114
* Create the ECC field corresponding to a 8-byte data field
131115
*
@@ -138,7 +122,7 @@ static uint8_t eccgenerate(uint64_t data)
138122
uint8_t result = 0;
139123

140124
for (i = 0; i < 8; i++)
141-
result |= parity(eccmatrix[i] & data) << i;
125+
result |= __builtin_parityll(eccmatrix[i] & data) << i;
142126

143127
return result;
144128
}

0 commit comments

Comments
 (0)