Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | LogicalResult scf::canonicalizeMinMaxOpInLoop(RewriterBase &rewriter, | ||||
Operation *op, | Operation *op, | ||||
LoopMatcherFn loopMatcher) { | LoopMatcherFn loopMatcher) { | ||||
FlatAffineValueConstraints constraints; | FlatAffineValueConstraints constraints; | ||||
DenseSet<Value> allIvs; | DenseSet<Value> allIvs; | ||||
// Find all iteration variables among `minOp`'s operands add constrain them. | // Find all iteration variables among `minOp`'s operands add constrain them. | ||||
for (Value operand : op->getOperands()) { | for (Value operand : op->getOperands()) { | ||||
// Skip duplicate ivs. | // Skip duplicate ivs. | ||||
if (llvm::is_contained(allIvs, operand)) | if (allIvs.contains(operand)) | ||||
continue; | continue; | ||||
// If `operand` is an iteration variable: Find corresponding loop | // If `operand` is an iteration variable: Find corresponding loop | ||||
// bounds and step. | // bounds and step. | ||||
Value iv = operand; | Value iv = operand; | ||||
OpFoldResult lb, ub, step; | OpFoldResult lb, ub, step; | ||||
if (failed(loopMatcher(operand, lb, ub, step))) | if (failed(loopMatcher(operand, lb, ub, step))) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |