mapleFU commented on code in PR #41690:
URL: https://github.com/apache/arrow/pull/41690#discussion_r1605673886
##########
cpp/src/arrow/util/bit_util.h:
##########
@@ -282,15 +282,19 @@ static inline int Log2(uint64_t x) {
// Bitmask selecting the k-th bit in a byte
// static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128};
-static constexpr uint8_t GetBitMask(uint8_t index) {
+template <typename T>
+static constexpr uint8_t GetBitMask(T index) {
// DCHECK(index >= 0 && index <= 7);
+ ARROW_COMPILER_ASSUME(index >= 0 && index <= 7);
return static_cast<uint8_t>(1) << index;
}
// the bitwise complement version of kBitmask
// static constexpr uint8_t kFlippedBitmask[] = {254, 253, 251, 247, 239, 223,
191, 127};
-static constexpr uint8_t GetFlippedBitMask(uint8_t index) {
+template <typename T>
+static constexpr uint8_t GetFlippedBitMask(T index) {
// DCHECK(index >= 0 && index <= 7);
+ ARROW_COMPILER_ASSUME(index >= 0 && index <= 7);
Review Comment:
I'm not fully understand this, `signed_index % 8` happens before the call to
GetBitmask doesn't means the code of `GetBitMask` cannot benifit from this? Or
you means the system might analyze `% 8` and do the assume itself?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]