Use compiler byteswap functions if available #14329

pull DesWurstes wants to merge 2 commits into bitcoin:master from DesWurstes:patch-2 changing 2 files +22 −1
  1. DesWurstes commented at 3:19 PM on September 26, 2018: contributor

    No description provided.

  2. Check for builtin swap functions 6c2f30ddd5
  3. Add byteswap functions c6fadc9eee
  4. practicalswift commented at 7:43 AM on September 27, 2018: contributor

    What would be the appropriate benchmark for this change?

  5. sipa commented at 11:55 AM on September 27, 2018: member

    I believe this won't have any effect. Modern compilers recognize the pattern used in the current code as byteswapping, and will use an appropriate native operation for it if available. I think it's likely the binary output is in fact identical before and after.

    That said, it's probably more clear and reliable to use the builtin when available.

  6. jgarzik commented at 12:08 PM on September 27, 2018: contributor

    Agree with @sipa 's first paragraph.

    Typically the modern compilers plus system headers do a better job, and are better maintained By The People Who Know These Things (gcc/llvm/glibc people).

  7. DesWurstes commented at 1:41 PM on September 27, 2018: contributor

    I've experimented: GCC can see that pattern since 4.5 and Clang can see it since 3.0. MSVC still can't recognize bswap64.

    So, closing it.

  8. DesWurstes closed this on Sep 27, 2018

  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me