MLIR  20.0.0git
Macros | Functions
LoopInvariantCodeMotionUtils.cpp File Reference
#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/SubsetOpInterface.h"
#include "llvm/Support/Debug.h"
#include <queue>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "licm"
 

Functions

static bool canBeHoisted (Operation *op, function_ref< bool(OpOperand &)> condition)
 Checks whether the given op can be hoisted by checking that. More...
 
static bool canBeHoisted (Operation *op, function_ref< bool(Value)> definedOutside)
 
static OpOperandgetSingleTerminatorUse (Value value)
 If the given value has a single use by an op that is a terminator, return that use. More...
 
static LoopLikeOpInterface hoistSubsetAtIterArg (RewriterBase &rewriter, LoopLikeOpInterface loopLike, BlockArgument iterArg)
 Hoist all subset ops that operate on the idx-th region iter_arg of the given loop-like op and index into loop-invariant subset locations. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "licm"

Definition at line 23 of file LoopInvariantCodeMotionUtils.cpp.

Function Documentation

◆ canBeHoisted() [1/2]

static bool canBeHoisted ( Operation op,
function_ref< bool(OpOperand &)>  condition 
)
static

Checks whether the given op can be hoisted by checking that.

  • the op and none of its contained operations depend on values inside of the loop (by means of calling definedOutside).
  • the op has no side-effects.

Definition at line 31 of file LoopInvariantCodeMotionUtils.cpp.

References mlir::WalkResult::advance(), mlir::Operation::hasTrait(), mlir::WalkResult::interrupt(), mlir::Operation::isAncestor(), and mlir::Operation::walk().

Referenced by canBeHoisted(), hoistSubsetAtIterArg(), and mlir::moveLoopInvariantCode().

◆ canBeHoisted() [2/2]

static bool canBeHoisted ( Operation op,
function_ref< bool(Value)>  definedOutside 
)
static

◆ getSingleTerminatorUse()

static OpOperand* getSingleTerminatorUse ( Value  value)
static

If the given value has a single use by an op that is a terminator, return that use.

Otherwise, return nullptr.

Definition at line 230 of file LoopInvariantCodeMotionUtils.cpp.

References mlir::detail::IROperandBase::getOwner(), mlir::Value::getUses(), mlir::Value::hasOneUse(), and mlir::Operation::hasTrait().

◆ hoistSubsetAtIterArg()

static LoopLikeOpInterface hoistSubsetAtIterArg ( RewriterBase rewriter,
LoopLikeOpInterface  loopLike,
BlockArgument  iterArg 
)
static

Hoist all subset ops that operate on the idx-th region iter_arg of the given loop-like op and index into loop-invariant subset locations.

Return the newly created loop op (that has extra iter_args) or the original loop op if nothing was hoisted.

Definition at line 321 of file LoopInvariantCodeMotionUtils.cpp.

References canBeHoisted(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::BlockArgument::getOwner(), mlir::Block::getParentOp(), mlir::RewriterBase::moveOpAfter(), mlir::RewriterBase::moveOpBefore(), and mlir::RewriterBase::replaceAllUsesWith().

Referenced by mlir::hoistLoopInvariantSubsets().