[libc-commits] [PATCH] D127097: [libc][math] Improved FBits performance and readablity.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jun 7 02:01:47 PDT 2022
sivachandra accepted this revision.
sivachandra added inline comments.
================
Comment at: libc/src/__support/FPUtil/FloatProperties.h:49
- static constexpr uint32_t BIT_WIDTH = sizeof(BitsType) << 3;
+ static constexpr uint32_t BIT_WIDTH = sizeof(BitsType) * 8;
----------------
orex wrote:
> sivachandra wrote:
> > Why is multiplication by 8 preferred over shift by 3?
> Just to improve readability. Everybody knows, that byte has 8 bits. But in previous representation it should:
> 1) Understand that `<< ` refers to explicit multiplication, but not bit/masks operations as everywhere else in the code.
> 2) Remember that 2^3=8.
> Of course, it is not a big problem, but the code is still complex and need attention. And we should not add extra complications for nothing.
To be absolutely clear, I am OK with using `* 8` in this patch. At the same time, I would have found the reasoning more appealing if it was like, "we should let the compilers choose the best instructions for the semantic of multiplying by 8."
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127097/new/
https://reviews.llvm.org/D127097
More information about the libc-commits
mailing list