forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit02a6a54
committed
Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT.
Test for the compiler builtins __builtin_clz, __builtin_ctz, and__builtin_popcount, and make use of these in preference tohandwritten C code if they're available. Create src/portinfrastructure for "leftmost one", "rightmost one", and "popcount"so as to centralize these decisions.On x86_64, __builtin_popcount generally won't make use of the POPCNTopcode because that's not universally supported yet. Provide codethat checks CPUID and then calls POPCNT via asm() if available.This requires indirecting through a function pointer, which isan annoying amount of overhead for a one-instruction operation,but it's probably not worth working harder than this for ourcurrent use-cases.I'm not sure we've found all the existing places that could profitfrom this new infrastructure; but we at least touched all theones that used copied-and-pasted versions of the bitmapset.c code,and got rid of multiple copies of the associated constant arrays.While at it, replace c-compiler.m4's one-per-builtin-functionmacros with a single one that can handle all the cases we needto worry about so far. Also, because I'm paranoid, make thosechecks into AC_LINK checks rather than just AC_COMPILE; theformer coding failed to verify that libgcc has support for thebuiltin, in cases where it's not inline code.David Rowley, Thomas Munro, Alvaro Herrera, Tom LaneDiscussion:https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com1 parent72880ac commit02a6a54
File tree
16 files changed
+879
-417
lines changed- config
- contrib
- intarray
- ltree
- pg_trgm
- src
- backend
- access/heap
- lib
- nodes
- utils/adt
- include
- port
- port
- tools/msvc
16 files changed
+879
-417
lines changedLines changed: 27 additions & 54 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
273 | 273 |
| |
274 | 274 |
| |
275 | 275 |
| |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 |
| - | |
284 |
| - | |
285 |
| - | |
286 |
| - | |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 |
| - | |
309 |
| - | |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
314 |
| - | |
315 |
| - | |
316 |
| - | |
317 |
| - | |
318 |
| - | |
319 |
| - | |
320 |
| - | |
321 |
| - | |
322 |
| - | |
323 |
| - | |
324 |
| - | |
325 |
| - | |
326 |
| - | |
327 |
| - | |
328 |
| - | |
329 |
| - | |
330 | 276 |
| |
331 | 277 |
| |
332 | 278 |
| |
| |||
423 | 369 |
| |
424 | 370 |
| |
425 | 371 |
| |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
426 | 399 |
| |
427 | 400 |
| |
428 | 401 |
| |
|
0 commit comments
Comments
(0)