Skip to content

[mlir] Fix shift overflow and warning on LLP64 platforms (Windows) #74002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

rnk
Copy link
Collaborator

@rnk rnk commented Nov 30, 2023

No description provided.

@rnk rnk requested a review from aartbik November 30, 2023 22:57
@llvmbot llvmbot added mlir:sparse Sparse compiler in MLIR mlir labels Nov 30, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 30, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-sparse

Author: Reid Kleckner (rnk)

Changes

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

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h (+3-3)
diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h b/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
index 9af42f00f91ed4e..ac91bfa5ae622dc 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
@@ -531,11 +531,11 @@ static_assert((isUniqueLT(LevelType::Dense) &&
 constexpr uint64_t encodeDim(uint64_t i, uint64_t cf, uint64_t cm) {
   if (cf != 0) {
     assert(cf <= 0xfffff && cm == 0 && i <= 0xfffff);
-    return (0x01L << 60) | (cf << 20) | i;
+    return (0x01ULL << 60) | (cf << 20) | i;
   }
   if (cm != 0) {
     assert(cm <= 0xfffff && i <= 0xfffff);
-    return (0x02L << 60) | (cm << 20) | i;
+    return (0x02ULL << 60) | (cm << 20) | i;
   }
   assert(i <= 0x0fffffffffffffffu);
   return i;
@@ -543,7 +543,7 @@ constexpr uint64_t encodeDim(uint64_t i, uint64_t cf, uint64_t cm) {
 constexpr uint64_t encodeLvl(uint64_t i, uint64_t c, uint64_t ii) {
   if (c != 0) {
     assert(c <= 0xfffff && ii <= 0xfffff && i <= 0xfffff);
-    return (0x03L << 60) | (c << 20) | (ii << 40) | i;
+    return (0x03ULL << 60) | (c << 20) | (ii << 40) | i;
   }
   assert(i <= 0x0fffffffffffffffu);
   return i;

Copy link
Contributor

@aartbik aartbik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@rnk rnk merged commit 341a51a into llvm:main Dec 6, 2023
@rnk rnk deleted the mlir-shift-fix branch December 6, 2023 17:26
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