[Mlir-commits] [mlir] 50e6c30 - [MLIR][Arith] Remove unused assertions

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Dec 23 00:02:51 PST 2022


Author: liqinweng
Date: 2022-12-23T16:01:51+08:00
New Revision: 50e6c306b1cb03fe398aebc41d1bef5b6c9d9bb0

URL: https://github.com/llvm/llvm-project/commit/50e6c306b1cb03fe398aebc41d1bef5b6c9d9bb0
DIFF: https://github.com/llvm/llvm-project/commit/50e6c306b1cb03fe398aebc41d1bef5b6c9d9bb0.diff

LOG: [MLIR][Arith] Remove unused assertions
We shouldn't be checking things that are guaranteed by the op's verifier.

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D140610

Added: 
    

Modified: 
    mlir/lib/Dialect/Arith/IR/ArithOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index f6446ea5ae4c..852fd0d08296 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -887,8 +887,6 @@ OpFoldResult arith::SubFOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult arith::MaxFOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "maxf takes two operands");
-
   // maxf(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -907,8 +905,6 @@ OpFoldResult arith::MaxFOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult MaxSIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "binary operation takes two operands");
-
   // maxsi(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -935,8 +931,6 @@ OpFoldResult MaxSIOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult MaxUIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "binary operation takes two operands");
-
   // maxui(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -961,8 +955,6 @@ OpFoldResult MaxUIOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult arith::MinFOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "minf takes two operands");
-
   // minf(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -981,8 +973,6 @@ OpFoldResult arith::MinFOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult MinSIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "binary operation takes two operands");
-
   // minsi(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -1009,8 +999,6 @@ OpFoldResult MinSIOp::fold(ArrayRef<Attribute> operands) {
 //===----------------------------------------------------------------------===//
 
 OpFoldResult MinUIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "binary operation takes two operands");
-
   // minui(x,x) -> x
   if (getLhs() == getRhs())
     return getRhs();
@@ -1245,8 +1233,6 @@ LogicalResult arith::ExtFOp::verify() { return verifyExtOp<FloatType>(*this); }
 //===----------------------------------------------------------------------===//
 
 OpFoldResult arith::TruncIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 1 && "unary operation takes one operand");
-
   // trunci(zexti(a)) -> a
   // trunci(sexti(a)) -> a
   if (matchPattern(getOperand(), m_Op<arith::ExtUIOp>()) ||
@@ -1293,8 +1279,6 @@ LogicalResult arith::TruncIOp::verify() {
 /// Perform safe const propagation for truncf, i.e. only propagate if FP value
 /// can be represented without precision loss or rounding.
 OpFoldResult arith::TruncFOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 1 && "unary operation takes one operand");
-
   auto constOperand = operands.front();
   if (!constOperand || !constOperand.isa<FloatAttr>())
     return {};
@@ -1535,8 +1519,6 @@ bool arith::BitcastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
 }
 
 OpFoldResult arith::BitcastOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 1 && "bitcast op expects 1 operand");
-
   auto resType = getType();
   auto operand = operands[0];
   if (!operand)
@@ -1653,8 +1635,6 @@ static std::optional<int64_t> getIntegerWidth(Type t) {
 }
 
 OpFoldResult arith::CmpIOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "cmpi takes two operands");
-
   // cmpi(pred, x, x)
   if (getLhs() == getRhs()) {
     auto val = applyCmpPredicateToEqualOperands(getPredicate());
@@ -1774,8 +1754,6 @@ bool mlir::arith::applyCmpPredicate(arith::CmpFPredicate predicate,
 }
 
 OpFoldResult arith::CmpFOp::fold(ArrayRef<Attribute> operands) {
-  assert(operands.size() == 2 && "cmpf takes two operands");
-
   auto lhs = operands.front().dyn_cast_or_null<FloatAttr>();
   auto rhs = operands.back().dyn_cast_or_null<FloatAttr>();
 


        


More information about the Mlir-commits mailing list