Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

Note that bit_width is implemented as:

std::numeric_limits::digits - llvm::countl_zero(Value);

Note that bit_width is implemented as:

  std::numeric_limits<T>::digits - llvm::countl_zero(Value);
@llvmbot
Copy link
Member

llvmbot commented May 6, 2025

@llvm/pr-subscribers-mlir-sparse

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)

Changes

Note that bit_width is implemented as:

std::numeric_limits<T>::digits - llvm::countl_zero(Value);


Full diff: https://github.com/llvm/llvm-project/pull/138648.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h (+1-1)
diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
index fca2629d72efc..d0a3f01afe871 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
@@ -122,7 +122,7 @@ class I64BitSet {
     unsigned m = llvm::countr_zero(storage);
     return m == 64 ? -1 : m;
   }
-  unsigned max() const { return 64 - llvm::countl_zero(storage); }
+  unsigned max() const { return llvm::bit_width(storage); }
   unsigned count() const { return llvm::popcount(storage); }
   bool empty() const { return storage == 0; }
 };

@kazutakahirata kazutakahirata requested review from nikic and shiltian May 7, 2025 03:23
@kazutakahirata kazutakahirata merged commit 7313c3b into llvm:main May 7, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_bit_width_mlir branch May 7, 2025 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:sparse Sparse compiler in MLIR mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants