46 PatternRewriter &rewriter)
const override {
50 arith::CmpIOp cmpiOp = cast<arith::CmpIOp>(op);
52 if (cmpiOp.getPredicate() != arith::CmpIPredicate::eq)
55 auto *lhsOp = cmpiOp.getLhs().getDefiningOp();
56 auto *rhsOp = cmpiOp.getRhs().getDefiningOp();
57 if (!((isa<memref::DimOp>(lhsOp) || isa<tensor::DimOp>(lhsOp)) &&
58 isa<arith::ConstantOp>(rhsOp)) &&
59 !((isa<memref::DimOp>(rhsOp) || isa<tensor::DimOp>(rhsOp)) &&
60 isa<arith::ConstantOp>(lhsOp)))
64 if (isa<memref::DimOp>(rhsOp) || isa<tensor::DimOp>(rhsOp))
65 std::swap(lhsOp, rhsOp);
68 auto constantOp = cast<arith::ConstantOp>(rhsOp);
69 if (cast<IntegerAttr>(constantOp.getValue()).getValue().getZExtValue() != 1)
73 auto constIndexOp = lhsOp->getOperand(1).getDefiningOp<arith::ConstantOp>();
78 cast<IntegerAttr>(constIndexOp.getValue()).getValue().getZExtValue();
79 auto inputDimType = dyn_cast<ShapedType>(lhsOp->getOperand(0).getType());
80 if (!inputDimType || !inputDimType.isDynamicDim(index))
83 rewriter.replaceOpWithNewOp<arith::ConstantOp>(
84 cmpiOp, rewriter.getIntegerAttr(rewriter.getI1Type(), 0));