Move the success/failure functions out of LogicalResult and into the mlir namespace.

PiperOrigin-RevId: 237712180
This commit is contained in:
River Riddle 2019-03-10 15:32:54 -07:00 committed by jpienaar
parent 2d2b40bce5
commit 0310d49f46
12 changed files with 96 additions and 91 deletions

View File

@ -682,9 +682,7 @@ private:
// constraints. Returns 'success' if the identifier was eliminated, and
// 'failure' otherwise.
inline LogicalResult gaussianEliminateId(unsigned position) {
return gaussianEliminateIds(position, position + 1) == 1
? LogicalResult::success()
: LogicalResult::failure();
return success(gaussianEliminateIds(position, position + 1) == 1);
}
// Eliminates identifiers from equality and inequality constraints

View File

@ -30,7 +30,6 @@
#include "mlir/IR/Block.h"
#include "mlir/IR/Location.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/SmallVector.h"
#include <memory>

View File

@ -23,18 +23,26 @@
namespace mlir {
// Values that can be used to signal success/failure. This should be used in
// conjunction with the 'succeeded' and 'failed' functions below.
// conjunction with the utility functions below.
struct LogicalResult {
enum ResultEnum { Success, Failure } value;
LogicalResult(ResultEnum v) : value(v) {}
/// Utility method to generate a success result.
static LogicalResult success() { return Success; }
/// Utility method to generate a failure result.
static LogicalResult failure() { return Failure; }
};
/// Utility function to generate a LogicalResult. If isSuccess is true a
/// `success` result is generated, otherwise a 'failure' result is generated.
inline LogicalResult success(bool isSuccess = true) {
return LogicalResult{isSuccess ? LogicalResult::Success
: LogicalResult::Failure};
}
/// Utility function to generate a LogicalResult. If isFailure is true a
/// `failure` result is generated, otherwise a 'success' result is generated.
inline LogicalResult failure(bool isFailure = true) {
return LogicalResult{isFailure ? LogicalResult::Failure
: LogicalResult::Success};
}
/// Utility function that returns true if the provided LogicalResult corresponds
/// to a success value.
inline bool succeeded(LogicalResult result) {

View File

@ -36,7 +36,7 @@ class FuncBuilder;
template <typename T> class OpPointer;
/// Unrolls this for instruction completely if the trip count is known to be
/// constant.
/// constant. Returns failure otherwise.
LogicalResult loopUnrollFull(OpPointer<AffineForOp> forOp);
/// Unrolls this for instruction by the specified unroll factor. Returns failure
/// if the loop cannot be unrolled either due to restrictions or due to invalid

View File

@ -107,9 +107,9 @@ LogicalResult mlir::getIndexSet(MutableArrayRef<OpPointer<AffineForOp>> forOps,
for (auto forOp : forOps) {
// Add constraints from forOp's bounds.
if (failed(domain->addAffineForOpDomain(forOp)))
return LogicalResult::failure();
return failure();
}
return LogicalResult::success();
return success();
}
// Computes the iteration domain for 'opInst' and populates 'indexSet', which
@ -386,7 +386,7 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap,
const ValuePositionMap &valuePosMap,
FlatAffineConstraints *dependenceDomain) {
if (dependenceDomain->getNumLocalIds() != 0)
return LogicalResult::failure();
return failure();
AffineMap srcMap = srcAccessMap.getAffineMap();
AffineMap dstMap = dstAccessMap.getAffineMap();
assert(srcMap.getNumResults() == dstMap.getNumResults());
@ -404,7 +404,7 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap,
// Get flattened expressions for the source destination maps.
if (failed(getFlattenedAffineExprs(srcMap, &srcFlatExprs, &srcLocalVarCst)) ||
failed(getFlattenedAffineExprs(dstMap, &destFlatExprs, &destLocalVarCst)))
return LogicalResult::failure();
return failure();
unsigned srcNumLocalIds = srcLocalVarCst.getNumLocalIds();
unsigned dstNumLocalIds = destLocalVarCst.getNumLocalIds();
@ -511,7 +511,7 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap,
dependenceDomain->addInequality(ineq);
}
return LogicalResult::success();
return success();
}
// Returns the number of outer loop common to 'src/dstDomain'.

View File

@ -82,7 +82,7 @@ static LogicalResult getFlattenedAffineExprs(
FlatAffineConstraints *localVarCst) {
if (exprs.empty()) {
localVarCst->reset(numDims, numSymbols);
return LogicalResult::success();
return success();
}
AffineExprFlattener flattener(numDims, numSymbols, exprs[0].getContext());
@ -90,7 +90,7 @@ static LogicalResult getFlattenedAffineExprs(
// local identifiers / expressions are shared.
for (auto expr : exprs) {
if (!expr.isPureAffine())
return LogicalResult::failure();
return failure();
flattener.walkPostOrder(expr);
}
@ -104,7 +104,7 @@ static LogicalResult getFlattenedAffineExprs(
localVarCst->clearAndCopyFrom(flattener.localVarCst);
}
return LogicalResult::success();
return success();
}
// Flattens 'expr' into 'flattenedExpr'. Returns failure if 'expr' was unable to
@ -128,7 +128,7 @@ LogicalResult mlir::getFlattenedAffineExprs(
FlatAffineConstraints *localVarCst) {
if (map.getNumResults() == 0) {
localVarCst->reset(map.getNumDims(), map.getNumSymbols());
return LogicalResult::success();
return success();
}
return ::getFlattenedAffineExprs(map.getResults(), map.getNumDims(),
map.getNumSymbols(), flattenedExprs,
@ -140,7 +140,7 @@ LogicalResult mlir::getFlattenedAffineExprs(
FlatAffineConstraints *localVarCst) {
if (set.getNumConstraints() == 0) {
localVarCst->reset(set.getNumDims(), set.getNumSymbols());
return LogicalResult::success();
return success();
}
return ::getFlattenedAffineExprs(set.getConstraints(), set.getNumDims(),
set.getNumSymbols(), flattenedExprs,
@ -614,7 +614,7 @@ LogicalResult FlatAffineConstraints::composeMap(AffineValueMap *vMap) {
&localCst))) {
LLVM_DEBUG(llvm::dbgs()
<< "composition unimplemented for semi-affine maps\n");
return LogicalResult::failure();
return failure();
}
assert(flatExprs.size() == vMap->getNumResults());
@ -673,7 +673,7 @@ LogicalResult FlatAffineConstraints::composeMap(AffineValueMap *vMap) {
addEquality(eqToAdd);
}
return LogicalResult::success();
return success();
}
// Turn a dimension into a symbol.
@ -737,7 +737,7 @@ FlatAffineConstraints::addAffineForOpDomain(ConstOpPointer<AffineForOp> forOp) {
// Pre-condition for this method.
if (!findId(*forOp->getInductionVar(), &pos)) {
assert(false && "Value not found");
return LogicalResult::failure();
return failure();
}
if (forOp->getStep() != 1)
@ -756,12 +756,12 @@ FlatAffineConstraints::addAffineForOpDomain(ConstOpPointer<AffineForOp> forOp) {
ncForOp->getLowerBoundOperands().end());
if (failed(addLowerOrUpperBound(pos, forOp->getLowerBoundMap(), lbOperands,
/*eq=*/false, /*lower=*/true)))
return LogicalResult::failure();
return failure();
}
if (forOp->hasConstantUpperBound()) {
addConstantUpperBound(pos, forOp->getConstantUpperBound() - step);
return LogicalResult::success();
return success();
}
// Non-constant upper bound case.
OpPointer<AffineForOp> ncForOp =
@ -1633,7 +1633,7 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap,
std::vector<SmallVector<int64_t, 8>> flatExprs;
if (failed(getFlattenedAffineExprs(boundMap, &flatExprs, &localVarCst))) {
LLVM_DEBUG(llvm::dbgs() << "semi-affine expressions not yet supported\n");
return LogicalResult::failure();
return failure();
}
// Merge and align with localVarCst.
@ -1688,7 +1688,7 @@ FlatAffineConstraints::addLowerOrUpperBound(unsigned pos, AffineMap boundMap,
: flatExpr[flatExpr.size() - 1] - 1;
eq ? addEquality(ineq) : addInequality(ineq);
}
return LogicalResult::success();
return success();
}
// Adds slice lower bounds represented by lower bounds in 'lbMaps' and upper
@ -1722,25 +1722,25 @@ LogicalResult FlatAffineConstraints::addSliceBounds(
lbMap.getResult(0) + 1 == ubMap.getResult(0)) {
if (failed(addLowerOrUpperBound(pos, lbMap, operands, /*eq=*/true,
/*lower=*/true)))
return LogicalResult::failure();
return failure();
if (failed(addLowerOrUpperBound(pos, lbMap, operands, /*eq=*/true,
/*lower=*/true)))
return LogicalResult::failure();
return failure();
continue;
}
if (lbMap && failed(addLowerOrUpperBound(pos, lbMap, operands, /*eq=*/false,
/*lower=*/true)))
return LogicalResult::failure();
return failure();
if (lbMap && failed(addLowerOrUpperBound(pos, lbMap, operands, /*eq=*/false,
/*lower=*/true)))
return LogicalResult::failure();
return failure();
if (ubMap && failed(addLowerOrUpperBound(pos, ubMap, operands, /*eq=*/false,
/*lower=*/false)))
return LogicalResult::failure();
return failure();
}
return LogicalResult::success();
return success();
}
void FlatAffineConstraints::addEquality(ArrayRef<int64_t> eq) {
@ -1931,13 +1931,13 @@ LogicalResult FlatAffineConstraints::constantFoldId(unsigned pos) {
assert(pos < getNumIds() && "invalid position");
int rowIdx;
if ((rowIdx = findEqualityToConstant(*this, pos)) == -1)
return LogicalResult::failure();
return failure();
// atEq(rowIdx, pos) is either -1 or 1.
assert(atEq(rowIdx, pos) * atEq(rowIdx, pos) == 1);
int64_t constVal = -atEq(rowIdx, getNumCols() - 1) / atEq(rowIdx, pos);
setAndEliminate(pos, constVal);
return LogicalResult::success();
return success();
}
void FlatAffineConstraints::constantFoldIdRange(unsigned pos, unsigned num) {
@ -2670,13 +2670,13 @@ FlatAffineConstraints::unionBoundingBox(const FlatAffineConstraints &otherCst) {
if (!extent.hasValue())
// TODO(bondhugula): symbolic extents when necessary.
// TODO(bondhugula): handle union if a dimension is unbounded.
return LogicalResult::failure();
return failure();
auto otherExtent =
other.getConstantBoundOnDimSize(d, &otherLb, &otherLbDivisor);
if (!otherExtent.hasValue() || lbDivisor != otherLbDivisor)
// TODO(bondhugula): symbolic extents when necessary.
return LogicalResult::failure();
return failure();
assert(lbDivisor > 0 && "divisor always expected to be positive");
@ -2691,7 +2691,7 @@ FlatAffineConstraints::unionBoundingBox(const FlatAffineConstraints &otherCst) {
auto constLb = getConstantLowerBound(d);
auto constOtherLb = other.getConstantLowerBound(d);
if (!constLb.hasValue() || !constOtherLb.hasValue())
return LogicalResult::failure();
return failure();
std::fill(minLb.begin(), minLb.end(), 0);
minLb.back() = std::min(constLb.getValue(), constOtherLb.getValue());
}
@ -2713,7 +2713,7 @@ FlatAffineConstraints::unionBoundingBox(const FlatAffineConstraints &otherCst) {
auto constUb = getConstantUpperBound(d);
auto constOtherUb = other.getConstantUpperBound(d);
if (!constUb.hasValue() || !constOtherUb.hasValue())
return LogicalResult::failure();
return failure();
std::fill(maxUb.begin(), maxUb.end(), 0);
maxUb.back() = std::max(constUb.getValue(), constOtherUb.getValue());
}
@ -2742,5 +2742,5 @@ FlatAffineConstraints::unionBoundingBox(const FlatAffineConstraints &otherCst) {
addInequality(boundingUbs[d]);
}
return LogicalResult::success();
return success();
}

View File

@ -82,7 +82,7 @@ ComputationSliceState::getAsConstraints(FlatAffineConstraints *cst) {
} else {
if (auto loop = getForInductionVarOwner(value)) {
if (failed(cst->addAffineForOpDomain(loop)))
return LogicalResult::failure();
return failure();
}
}
}
@ -92,7 +92,7 @@ ComputationSliceState::getAsConstraints(FlatAffineConstraints *cst) {
assert(succeeded(ret) &&
"should not fail as we never have semi-affine slice maps");
(void)ret;
return LogicalResult::success();
return success();
}
// Clears state bounds and operand state.
@ -195,7 +195,7 @@ LogicalResult MemRefRegion::compute(Instruction *inst, unsigned loopDepth,
extractForInductionVars(ivs, &regionSymbols);
// A rank 0 memref has a 0-d region.
cst.reset(rank, loopDepth, 0, regionSymbols);
return LogicalResult::success();
return success();
}
// Build the constraints for this region.
@ -237,7 +237,7 @@ LogicalResult MemRefRegion::compute(Instruction *inst, unsigned loopDepth,
// TODO(bondhugula): rewrite this to use getInstIndexSet; this way
// conditionals will be handled when the latter supports it.
if (failed(cst.addAffineForOpDomain(loop)))
return LogicalResult::failure();
return failure();
} else {
// Has to be a valid symbol.
auto *symbol = operand;
@ -270,7 +270,7 @@ LogicalResult MemRefRegion::compute(Instruction *inst, unsigned loopDepth,
if (failed(cst.composeMap(&accessValueMap))) {
inst->emitError("getMemRefRegion: compose affine map failed");
LLVM_DEBUG(accessValueMap.getAffineMap().dump());
return LogicalResult::failure();
return failure();
}
// Set all identifiers appearing after the first 'rank' identifiers as
@ -306,7 +306,7 @@ LogicalResult MemRefRegion::compute(Instruction *inst, unsigned loopDepth,
LLVM_DEBUG(llvm::dbgs() << "Memory region:\n");
LLVM_DEBUG(cst.dump());
return LogicalResult::success();
return success();
}
// TODO(mlir-team): improve/complete this when we have target data.
@ -380,7 +380,7 @@ LogicalResult mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
MemRefRegion region(opInst->getLoc());
if (failed(region.compute(opInst, /*loopDepth=*/0)))
return LogicalResult::success();
return success();
LLVM_DEBUG(llvm::dbgs() << "Memory region");
LLVM_DEBUG(region.getConstraints()->dump());
@ -420,7 +420,7 @@ LogicalResult mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
"memref out of lower bound access along dimension #" + Twine(r + 1));
}
}
return outOfBounds ? LogicalResult::failure() : LogicalResult::success();
return failure(outOfBounds);
}
// Explicitly instantiate the template so that the compiler knows we need them!
@ -486,7 +486,7 @@ LogicalResult mlir::getBackwardComputationSliceState(
if (!checkMemrefAccessDependence(
srcAccess, dstAccess, /*loopDepth=*/1, &dependenceConstraints,
/*dependenceComponents=*/nullptr, /*allowRAR=*/readReadAccesses)) {
return LogicalResult::failure();
return failure();
}
// Get loop nest surrounding src operation.
SmallVector<OpPointer<AffineForOp>, 4> srcLoopIVs;
@ -499,7 +499,7 @@ LogicalResult mlir::getBackwardComputationSliceState(
unsigned numDstLoopIVs = dstLoopIVs.size();
if (dstLoopDepth > numDstLoopIVs) {
dstAccess.opInst->emitError("invalid destination loop depth");
return LogicalResult::failure();
return failure();
}
// Project out dimensions other than those up to 'dstLoopDepth'.
@ -550,7 +550,7 @@ LogicalResult mlir::getBackwardComputationSliceState(
break;
}
return LogicalResult::success();
return success();
}
/// Creates a computation slice of the loop nest surrounding 'srcOpInst',

View File

@ -61,7 +61,7 @@ LogicalResult FunctionPassBase::run(Function *fn,
}
// Return if the pass signaled a failure.
return passFailed ? LogicalResult::failure() : LogicalResult::success();
return failure(passFailed);
}
/// Forwarding function to execute this pass.
@ -90,7 +90,7 @@ LogicalResult ModulePassBase::run(Module *module, ModuleAnalysisManager &mam) {
}
// Return if the pass signaled a failure.
return passFailed ? LogicalResult::failure() : LogicalResult::success();
return failure(passFailed);
}
//===----------------------------------------------------------------------===//
@ -172,8 +172,8 @@ LogicalResult detail::FunctionPassExecutor::run(Function *function,
// Run each of the held passes.
for (auto &pass : passes)
if (failed(pass->run(function, fam)))
return LogicalResult::failure();
return LogicalResult::success();
return failure();
return success();
}
/// Run all of the passes in this manager over the current module.
@ -182,8 +182,8 @@ LogicalResult detail::ModulePassExecutor::run(Module *module,
// Run each of the held passes.
for (auto &pass : passes)
if (failed(pass->run(module, mam)))
return LogicalResult::failure();
return LogicalResult::success();
return failure();
return success();
}
//===----------------------------------------------------------------------===//

View File

@ -142,7 +142,7 @@ LogicalResult impl::FunctionConversion::convertOpWithSuccessors(
llvm::makeArrayRef(operands.data(),
operands.data() + firstSuccessorOperand),
destinations, operandsPerDestination, builder);
return LogicalResult::success();
return success();
}
LogicalResult
@ -155,11 +155,11 @@ impl::FunctionConversion::convertOp(DialectOpConversion *converter,
auto results = converter->rewrite(op, operands, builder);
if (results.size() != op->getNumResults())
return (op->emitError("rewriting produced a different number of results"),
LogicalResult::failure());
failure());
for (unsigned i = 0, e = results.size(); i < e; ++i)
mapping.map(op->getResult(i), results[i]);
return LogicalResult::success();
return success();
}
LogicalResult
@ -174,7 +174,7 @@ impl::FunctionConversion::convertBlock(Block *block, FuncBuilder &builder,
for (Instruction &inst : *block) {
if (inst.getNumBlockLists() != 0) {
inst.emitError("unsupported region instruction");
return LogicalResult::failure();
return failure();
}
// Find the first matching conversion and apply it.
@ -185,9 +185,9 @@ impl::FunctionConversion::convertBlock(Block *block, FuncBuilder &builder,
if (inst.getNumSuccessors() != 0) {
if (failed(convertOpWithSuccessors(conversion, &inst, builder)))
return LogicalResult::failure();
return failure();
} else if (failed(convertOp(conversion, &inst, builder))) {
return LogicalResult::failure();
return failure();
}
converted = true;
break;
@ -202,9 +202,9 @@ impl::FunctionConversion::convertBlock(Block *block, FuncBuilder &builder,
if (visitedBlocks.count(succ) != 0)
continue;
if (failed(convertBlock(succ, builder, visitedBlocks)))
return LogicalResult::failure();
return failure();
}
return LogicalResult::success();
return success();
}
Function *impl::FunctionConversion::convertFunction(Function *f) {
@ -267,7 +267,7 @@ LogicalResult impl::FunctionConversion::convert(DialectConversion *conversion,
LogicalResult impl::FunctionConversion::run(Module *module) {
if (!module)
return LogicalResult::failure();
return failure();
MLIRContext *context = module->getContext();
conversions = dialectConversion->initConverters(context);
@ -283,7 +283,7 @@ LogicalResult impl::FunctionConversion::run(Module *module) {
for (auto *func : originalFuncs) {
Function *converted = convertFunction(func);
if (!converted)
return LogicalResult::failure();
return failure();
auto origFuncAttr = FunctionAttr::get(func, context);
auto convertedFuncAttr = FunctionAttr::get(converted, context);
@ -305,7 +305,7 @@ LogicalResult impl::FunctionConversion::run(Module *module) {
for (auto *func : convertedFuncs)
module->getFunctions().push_back(func);
return LogicalResult::success();
return success();
}
// Create a function type with arguments and results converted, and argument

View File

@ -237,7 +237,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<OpPointer<AffineForOp>> band,
if (!cst.isHyperRectangular(0, width)) {
rootAffineForOp->emitError("tiled code generation unimplemented for the "
"non-hyperrectangular case");
return LogicalResult::failure();
return failure();
}
constructTiledIndexSetHyperRect(origLoops, newLoops, tileSizes);
@ -249,7 +249,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<OpPointer<AffineForOp>> band,
// Erase the old loop nest.
rootAffineForOp->erase();
return LogicalResult::success();
return success();
}
// Identify valid and profitable bands of loops to tile. This is currently just

View File

@ -153,13 +153,13 @@ LogicalResult mlir::loopUnrollJamByFactor(OpPointer<AffineForOp> forOp,
assert(unrollJamFactor >= 1 && "unroll jam factor should be >= 1");
if (unrollJamFactor == 1 || forOp->getBody()->empty())
return LogicalResult::failure();
return failure();
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
if (!mayBeConstantTripCount.hasValue() &&
getLargestDivisorOfTripCount(forOp) % unrollJamFactor != 0)
return LogicalResult::failure();
return failure();
auto lbMap = forOp->getLowerBoundMap();
auto ubMap = forOp->getUpperBoundMap();
@ -169,18 +169,18 @@ LogicalResult mlir::loopUnrollJamByFactor(OpPointer<AffineForOp> forOp,
// do such unrolling for a Function would be to specialize the loop for the
// 'hotspot' case and unroll that hotspot.
if (lbMap.getNumResults() != 1 || ubMap.getNumResults() != 1)
return LogicalResult::failure();
return failure();
// Same operand list for lower and upper bound for now.
// TODO(bondhugula): handle bounds with different sets of operands.
if (!forOp->matchingBoundOperandList())
return LogicalResult::failure();
return failure();
// If the trip count is lower than the unroll jam factor, no unroll jam.
// TODO(bondhugula): option to specify cleanup loop unrolling.
if (mayBeConstantTripCount.hasValue() &&
mayBeConstantTripCount.getValue() < unrollJamFactor)
return LogicalResult::failure();
return failure();
auto *forInst = forOp->getInstruction();
@ -241,7 +241,7 @@ LogicalResult mlir::loopUnrollJamByFactor(OpPointer<AffineForOp> forOp,
// Promote the loop body up if this has turned into a single iteration loop.
promoteIfSingleIteration(forOp);
return LogicalResult::success();
return success();
}
static PassRegistration<LoopUnrollAndJam> pass("loop-unroll-jam",

View File

@ -94,11 +94,11 @@ AffineMap mlir::getCleanupLoopLowerBound(ConstOpPointer<AffineForOp> forOp,
LogicalResult mlir::promoteIfSingleIteration(OpPointer<AffineForOp> forOp) {
Optional<uint64_t> tripCount = getConstantTripCount(forOp);
if (!tripCount.hasValue() || tripCount.getValue() != 1)
return LogicalResult::failure();
return failure();
// TODO(mlir-team): there is no builder for a max.
if (forOp->getLowerBoundMap().getNumResults() != 1)
return LogicalResult::failure();
return failure();
// Replaces all IV uses to its single iteration value.
auto *iv = forOp->getInductionVar();
@ -129,7 +129,7 @@ LogicalResult mlir::promoteIfSingleIteration(OpPointer<AffineForOp> forOp) {
block->getInstructions().splice(Block::iterator(forInst),
forOp->getBody()->getInstructions());
forOp->erase();
return LogicalResult::success();
return success();
}
/// Promotes all single iteration for inst's in the Function, i.e., moves
@ -215,7 +215,7 @@ LogicalResult mlir::instBodySkew(OpPointer<AffineForOp> forOp,
ArrayRef<uint64_t> shifts,
bool unrollPrologueEpilogue) {
if (forOp->getBody()->empty())
return LogicalResult::success();
return success();
// If the trip counts aren't constant, we would need versioning and
// conditional guards (or context information to prevent such versioning). The
@ -224,7 +224,7 @@ LogicalResult mlir::instBodySkew(OpPointer<AffineForOp> forOp,
auto mayBeConstTripCount = getConstantTripCount(forOp);
if (!mayBeConstTripCount.hasValue()) {
LLVM_DEBUG(forOp->emitNote("non-constant trip count loop not handled"));
return LogicalResult::success();
return success();
}
uint64_t tripCount = mayBeConstTripCount.getValue();
@ -243,7 +243,7 @@ LogicalResult mlir::instBodySkew(OpPointer<AffineForOp> forOp,
// Such large shifts are not the typical use case.
if (maxShift >= numChildInsts) {
forOp->emitWarning("not shifting because shifts are unrealistically large");
return LogicalResult::success();
return success();
}
// An array of instruction groups sorted by shift amount; each group has all
@ -329,7 +329,7 @@ LogicalResult mlir::instBodySkew(OpPointer<AffineForOp> forOp,
epilogue->getInstruction() != prologue->getInstruction())
loopUnrollFull(epilogue);
return LogicalResult::success();
return success();
}
/// Unrolls this loop completely.
@ -342,7 +342,7 @@ LogicalResult mlir::loopUnrollFull(OpPointer<AffineForOp> forOp) {
}
return loopUnrollByFactor(forOp, tripCount);
}
return LogicalResult::failure();
return failure();
}
/// Unrolls and jams this loop by the specified factor or by the trip count (if
@ -367,7 +367,7 @@ LogicalResult mlir::loopUnrollByFactor(OpPointer<AffineForOp> forOp,
return promoteIfSingleIteration(forOp);
if (forOp->getBody()->empty())
return LogicalResult::failure();
return failure();
auto lbMap = forOp->getLowerBoundMap();
auto ubMap = forOp->getUpperBoundMap();
@ -377,12 +377,12 @@ LogicalResult mlir::loopUnrollByFactor(OpPointer<AffineForOp> forOp,
// do such unrolling for a Function would be to specialize the loop for the
// 'hotspot' case and unroll that hotspot.
if (lbMap.getNumResults() != 1 || ubMap.getNumResults() != 1)
return LogicalResult::failure();
return failure();
// Same operand list for lower and upper bound for now.
// TODO(bondhugula): handle bounds with different operand lists.
if (!forOp->matchingBoundOperandList())
return LogicalResult::failure();
return failure();
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
@ -390,7 +390,7 @@ LogicalResult mlir::loopUnrollByFactor(OpPointer<AffineForOp> forOp,
// TODO(bondhugula): option to specify cleanup loop unrolling.
if (mayBeConstantTripCount.hasValue() &&
mayBeConstantTripCount.getValue() < unrollFactor)
return LogicalResult::failure();
return failure();
// Generate the cleanup loop if trip count isn't a multiple of unrollFactor.
Instruction *forInst = forOp->getInstruction();
@ -451,7 +451,7 @@ LogicalResult mlir::loopUnrollByFactor(OpPointer<AffineForOp> forOp,
// Promote the loop body up if this has turned into a single iteration loop.
promoteIfSingleIteration(forOp);
return LogicalResult::success();
return success();
}
/// Performs loop interchange on 'forOpA' and 'forOpB', where 'forOpB' is