I have a bug when I create arith::IndexCastOp in my pass. In the original old version of llvm there was no problem.Now I am using the latest version of llvm.Here is my code.
IntegerType i64Type = rewriter.getI64Type();
Value aArrayExtractOp =
rewriter.create<memref::ExtractAlignedPointerAsIndexOp>(loc, resultType,
aArray);
Value aArrayindexCastOp =
rewriter.create<arith::IndexCastOp>(loc, i64Type, aArrayExtractOp);
Value bArrayExtractOp =
rewriter.create<memref::ExtractAlignedPointerAsIndexOp>(loc, resultType,
bArray);
// There will report error.
Value bArrayindexCastOp =
rewriter.create<arith::IndexCastOp>(loc, i64Type, bArrayExtractOp);
Value cArrayExtractOp =
rewriter.create<memref::ExtractAlignedPointerAsIndexOp>(loc, resultType,
cArray);
Value cArrayindexCastOp =
rewriter.create<arith::IndexCastOp>(loc, i64Type, cArrayExtractOp);
Value dArrayExtractOp =
rewriter.create<memref::ExtractAlignedPointerAsIndexOp>(loc, resultType,
dArray);
Value dArrayindexCastOp =
rewriter.create<arith::IndexCastOp>(loc, i64Type, dArrayExtractOp);
Here is my debugging process.What you can see is that the first time create arith::IndexCastOp in pass succeeds, and the second time create arith::IndexCastOp, it reports an error directly.I am not sure why the first creation of arith::index_cast succeeded, but the second creation of arith::index_cast failed.If anyone can help me, I would be grateful.Thanks!
mlir-opt tile-conv.mlir -lower-gemmini -debug
* Pattern : 'gemmini.tile_conv -> ()' {
Trying to match "GemminiTileConvOpLowering"
** Insert : 'memref.extract_aligned_pointer_as_index'(0x559142dcb970)
** Insert : 'arith.index_cast'(0x559142dcba00)
** Insert : 'memref.extract_aligned_pointer_as_index'(0x559142dcba90)
mlir-opt::/llvm/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = mlir::detail::TypedValue<mlir::IndexType>; From = mlir::OpResult]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.