[Mlir-commits] [mlir] 57a6e6f - [mlir] avoid comparing char with `~0x00` literal. (#186441)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Mar 13 10:27:53 PDT 2026


Author: Chenguang Wang
Date: 2026-03-13T10:27:48-07:00
New Revision: 57a6e6f9ceb292f847f81b4e2c4e2623397ac982

URL: https://github.com/llvm/llvm-project/commit/57a6e6f9ceb292f847f81b4e2c4e2623397ac982
DIFF: https://github.com/llvm/llvm-project/commit/57a6e6f9ceb292f847f81b4e2c4e2623397ac982.diff

LOG: [mlir] avoid comparing char with `~0x00` literal. (#186441)

Introduced in #186221. This is actually incorrect; when we compare
char with int, due to arithmetic conversion, the char may be sign
extended or not (depending on whether `char` is signed), so the
comparison does not always have the expected behavior. But the
RHS will always be 0xFFFFFFFF.

Added: 
    

Modified: 
    mlir/lib/IR/BuiltinDialectBytecode.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/BuiltinDialectBytecode.cpp b/mlir/lib/IR/BuiltinDialectBytecode.cpp
index 9a5a598633d8a..f7430784dd222 100644
--- a/mlir/lib/IR/BuiltinDialectBytecode.cpp
+++ b/mlir/lib/IR/BuiltinDialectBytecode.cpp
@@ -180,7 +180,7 @@ readDenseTypedElementsAttr(DialectBytecodeReader &reader, ShapedType type,
   size_t packedSize = llvm::divideCeil(numElements, 8);
 
   // Unpack splats to single element 0x01 to match unpacked splat format.
-  if (blob.size() == 1 && blob[0] == ~0x00) {
+  if (blob.size() == 1 && blob[0] == static_cast<char>(~0x00)) {
     rawData.resize(1);
     rawData[0] = 0x01;
     return success();


        


More information about the Mlir-commits mailing list