Lines Matching defs:forOp

119 static LogicalResult peelForLoop(RewriterBase &b, ForOp forOp,
122 auto lbInt = getConstantIntValue(forOp.getLowerBound());
123 auto ubInt = getConstantIntValue(forOp.getUpperBound());
124 auto stepInt = getConstantIntValue(forOp.getStep());
138 SmallVector<Value> operands{forOp.getLowerBound(), forOp.getUpperBound(),
139 forOp.getStep()};
148 b.setInsertionPoint(forOp);
149 auto loc = forOp.getLoc();
151 ValueRange{forOp.getLowerBound(),
152 forOp.getUpperBound(),
153 forOp.getStep()});
156 b.setInsertionPointAfter(forOp);
157 partialIteration = cast<ForOp>(b.clone(*forOp.getOperation()));
159 b.replaceAllUsesWith(forOp.getResults(), partialIteration->getResults());
160 partialIteration.getInitArgsMutable().assign(forOp->getResults());
163 b.modifyOpInPlace(forOp,
164 [&]() { forOp.getUpperBoundMutable().assign(splitBound); });
169 static void rewriteAffineOpAfterPeeling(RewriterBase &rewriter, ForOp forOp,
172 Value mainIv = forOp.getInductionVar();
174 assert(forOp.getStep() == partialIteration.getStep() &&
176 Value step = forOp.getStep();
178 forOp.walk([&](Operation *affineOp) {
196 ForOp forOp,
198 Value previousUb = forOp.getUpperBound();
200 if (failed(peelForLoop(rewriter, forOp, partialIteration, splitBound)))
204 rewriteAffineOpAfterPeeling(rewriter, forOp, partialIteration, previousUb);
214 LogicalResult mlir::scf::peelForLoopFirstIteration(RewriterBase &b, ForOp forOp,
217 auto lbInt = getConstantIntValue(forOp.getLowerBound());
218 auto ubInt = getConstantIntValue(forOp.getUpperBound());
219 auto stepInt = getConstantIntValue(forOp.getStep());
230 b.setInsertionPoint(forOp);
231 auto loc = forOp.getLoc();
233 loc, ubMap, ValueRange{forOp.getLowerBound(), forOp.getStep()});
237 map.map(forOp.getUpperBound(), splitBound);
238 firstIteration = cast<ForOp>(b.clone(*forOp.getOperation(), map));
241 b.modifyOpInPlace(forOp, [&]() {
242 forOp.getInitArgsMutable().assign(firstIteration->getResults());
243 forOp.getLowerBoundMutable().assign(splitBound);
258 LogicalResult matchAndRewrite(ForOp forOp,
261 if (forOp->hasAttr(kPeeledLoopLabel))
268 peelForLoopFirstIteration(rewriter, forOp, partialIteration))) {
275 Operation *op = forOp.getOperation();
283 peelForLoopAndSimplifyBounds(rewriter, forOp, partialIteration)))
292 rewriter.modifyOpInPlace(forOp, [&]() {
293 forOp->setAttr(kPeeledLoopLabel, rewriter.getUnitAttr());