diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index de620e1e2602..bc95c2f95927 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -266,11 +266,13 @@ std::vector tblgen::Pattern::getConstraints() const { } int tblgen::Pattern::getBenefit() const { - // The default benefit value is a heristic with number of ops in the source + // The initial benefit value is a heuristic with number of ops in the source // pattern. - int defaultBenefit = getSourcePattern().getNumOps(); + int initBenefit = getSourcePattern().getNumOps(); llvm::DagInit *delta = def.getValueAsDag("benefitDelta"); - if (delta->getNumArgs() != 1 || !isa(delta->getArg(0))) - PrintFatalError(def.getLoc(), "The 'AddedBenefit' can only be an integer"); - return defaultBenefit + dyn_cast(delta->getArg(0))->getValue(); + if (delta->getNumArgs() != 1 || !isa(delta->getArg(0))) { + PrintFatalError(def.getLoc(), + "The 'addBenefit' takes and only takes one integer value"); + } + return initBenefit + dyn_cast(delta->getArg(0))->getValue(); }