[Mlir-commits] [mlir] [mlir][arith] Support bitcast with index type (PR #121455)

Jianjian Guan llvmlistbot at llvm.org
Thu Jan 2 00:38:13 PST 2025


================
@@ -1723,7 +1723,18 @@ bool arith::BitcastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
   if (!srcType || !dstType)
     return false;
 
-  return srcType.getIntOrFloatBitWidth() == dstType.getIntOrFloatBitWidth();
+  unsigned srcWidth, dstWidth;
+  if (auto indexTy = dyn_cast<IndexType>(srcType))
+    srcWidth = IndexType::kInternalStorageBitWidth;
----------------
jacquesguan wrote:

In mlir/lib/IR/BuiltinDialectBytecode.cpp
```
static unsigned getIntegerBitWidth(DialectBytecodeReader &reader, Type type) {
```
This function also uses `kInternalStorageBitWidth` as the bit width of index type.

https://github.com/llvm/llvm-project/pull/121455


More information about the Mlir-commits mailing list