[Mlir-commits] [mlir] [mlir][affine] remove divide zero check when simplifer affineMap (#64622) (PR #68519)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Nov 3 20:59:59 PDT 2023
================
@@ -75,117 +146,111 @@ class AffineExprVisitor {
RetTy walkPostOrder(AffineExpr expr) {
static_assert(std::is_base_of<AffineExprVisitor, SubClass>::value,
"Must instantiate with a derived type of AffineExprVisitor");
+ auto self = static_cast<SubClass *>(this);
switch (expr.getKind()) {
case AffineExprKind::Add: {
auto binOpExpr = expr.cast<AffineBinaryOpExpr>();
walkOperandsPostOrder(binOpExpr);
- return static_cast<SubClass *>(this)->visitAddExpr(binOpExpr);
+ return self->visitAddExpr(binOpExpr);
}
case AffineExprKind::Mul: {
auto binOpExpr = expr.cast<AffineBinaryOpExpr>();
walkOperandsPostOrder(binOpExpr);
- return static_cast<SubClass *>(this)->visitMulExpr(binOpExpr);
+ return self->visitMulExpr(binOpExpr);
}
case AffineExprKind::Mod: {
auto binOpExpr = expr.cast<AffineBinaryOpExpr>();
walkOperandsPostOrder(binOpExpr);
- return static_cast<SubClass *>(this)->visitModExpr(binOpExpr);
+ return self->visitModExpr(binOpExpr);
}
case AffineExprKind::FloorDiv: {
auto binOpExpr = expr.cast<AffineBinaryOpExpr>();
walkOperandsPostOrder(binOpExpr);
- return static_cast<SubClass *>(this)->visitFloorDivExpr(binOpExpr);
+ return self->visitFloorDivExpr(binOpExpr);
}
case AffineExprKind::CeilDiv: {
auto binOpExpr = expr.cast<AffineBinaryOpExpr>();
walkOperandsPostOrder(binOpExpr);
- return static_cast<SubClass *>(this)->visitCeilDivExpr(binOpExpr);
+ return self->visitCeilDivExpr(binOpExpr);
}
case AffineExprKind::Constant:
- return static_cast<SubClass *>(this)->visitConstantExpr(
- expr.cast<AffineConstantExpr>());
+ return self->visitConstantExpr(expr.cast<AffineConstantExpr>());
----------------
lipracer wrote:
> Using `cast` method [instead of the free function](https://mlir.llvm.org/deprecation/).
If llvm:: cast is used, it will result in a compilation error: 'classof' is not a member of 'mlir:: AffineSymbolExpr'
Here we need to implement CastInfo<T, AffineExpr>, and I have submitted another [PR]( https://github.com/llvm/llvm-project/pull/71269)
https://github.com/llvm/llvm-project/pull/68519
More information about the Mlir-commits
mailing list