MLIR
20.0.0git
|
#include "mlir/Dialect/SCF/Transforms/Passes.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/DenseMap.h"
#include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
Go to the source code of this file.
Namespaces | |
mlir | |
Include the generated interface declarations. | |
Macros | |
#define | GEN_PASS_DEF_SCFFORLOOPPEELING |
#define | GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION |
#define | GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION |
Functions | |
static void | specializeParallelLoopForUnrolling (ParallelOp op) |
Rewrite a parallel loop with bounds defined by an affine.min with a constant into 2 loops after checking if the bounds are equal to that constant. More... | |
static void | specializeForLoopForUnrolling (ForOp op) |
Rewrite a for loop with bounds defined by an affine.min with a constant into 2 loops after checking if the bounds are equal to that constant. More... | |
static LogicalResult | peelForLoop (RewriterBase &b, ForOp forOp, ForOp &partialIteration, Value &splitBound) |
Rewrite a for loop with bounds/step that potentially do not divide evenly into a for loop where the step divides the iteration space evenly, followed by an scf.if for the last (partial) iteration (if any). More... | |
static void | rewriteAffineOpAfterPeeling (RewriterBase &rewriter, ForOp forOp, ForOp partialIteration, Value previousUb) |
Variables | |
static constexpr char | kPeeledLoopLabel [] = "__peeled_loop__" |
static constexpr char | kPartialIterationLabel [] = "__partial_iteration__" |
#define GEN_PASS_DEF_SCFFORLOOPPEELING |
Definition at line 30 of file LoopSpecialization.cpp.
#define GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION |
Definition at line 31 of file LoopSpecialization.cpp.
#define GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION |
Definition at line 32 of file LoopSpecialization.cpp.
|
static |
Rewrite a for loop with bounds/step that potentially do not divide evenly into a for loop where the step divides the iteration space evenly, followed by an scf.if for the last (partial) iteration (if any).
This function rewrites the given scf.for loop in-place and creates a new scf.if operation for the last iteration. It replaces all uses of the unpeeled loop with the results of the newly generated scf.if.
The newly generated scf.if operation is returned via ifOp
. The boundary at which the loop is split (new upper bound) is returned via splitBound
. The return value indicates whether the loop was rewritten or not.
Definition at line 119 of file LoopSpecialization.cpp.
References mlir::bindSymbols(), mlir::OpBuilder::clone(), mlir::OpBuilder::createOrFold(), mlir::affine::fullyComposeAffineMapAndOperands(), mlir::AffineMap::get(), mlir::getConstantIntValue(), mlir::Builder::getContext(), mlir::AffineMap::getResult(), mlir::RewriterBase::modifyOpInPlace(), mlir::RewriterBase::replaceAllUsesWith(), mlir::OpBuilder::setInsertionPoint(), and mlir::OpBuilder::setInsertionPointAfter().
|
static |
Definition at line 169 of file LoopSpecialization.cpp.
References mlir::WalkResult::advance(), and mlir::scf::rewritePeeledMinMaxOp().
|
static |
Rewrite a for loop with bounds defined by an affine.min with a constant into 2 loops after checking if the bounds are equal to that constant.
This is beneficial if the loop will almost always have the constant bound and that version can be fully unrolled and vectorized.
Definition at line 83 of file LoopSpecialization.cpp.
References mlir::Operation::clone(), mlir::sparse_tensor::constantIndex(), mlir::OpBuilder::create(), mlir::Operation::erase(), mlir::IRMapping::map(), max(), and min().
|
static |
Rewrite a parallel loop with bounds defined by an affine.min with a constant into 2 loops after checking if the bounds are equal to that constant.
This is beneficial if the loop will almost always have the constant bound and that version can be fully unrolled and vectorized.
Definition at line 45 of file LoopSpecialization.cpp.
References mlir::Operation::clone(), mlir::sparse_tensor::constantIndex(), mlir::OpBuilder::create(), mlir::Operation::erase(), mlir::IRMapping::map(), max(), and min().
|
staticconstexpr |
Definition at line 250 of file LoopSpecialization.cpp.
|
staticconstexpr |
Definition at line 249 of file LoopSpecialization.cpp.