Commit 69acbdb
RAS/AMD/ATL: Replace bitwise_xor_bits() with hweight16()
Doing hweight16() and checking whether the lsb is set is functionally
equivalent to what bitwise_xor_bits() does. In addition, it results in better
generated code as before gcc would inline the function 4 times. With hweight16(),
the resulting code boils down to 2 instructions - POPCNT and AND, and all
relevant CPUs support POPCNT.
An alternative would have been to use the __builtin_parity() function provided
by both Clang/GCC, however under some circumstances the compiler can choose not
to inline it but generate a library call which is unsupported in the kernel.
No functional changes.
[ bp: Massage commit message. ]
Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20251124142517.1708451-1-nik.borisov@suse.com1 parent 187d1b2 commit 69acbdb
1 file changed
Lines changed: 5 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 52 | | |
64 | 53 | | |
65 | 54 | | |
| |||
250 | 239 | | |
251 | 240 | | |
252 | 241 | | |
253 | | - | |
254 | | - | |
| 242 | + | |
| 243 | + | |
255 | 244 | | |
256 | 245 | | |
257 | 246 | | |
258 | 247 | | |
259 | 248 | | |
260 | | - | |
261 | | - | |
| 249 | + | |
| 250 | + | |
262 | 251 | | |
263 | | - | |
| 252 | + | |
264 | 253 | | |
265 | 254 | | |
266 | 255 | | |
| |||
0 commit comments