MLIR  22.0.0git
Namespaces | Macros | Functions
IfConditionPropagation.cpp File Reference
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Transforms/Passes.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_SCFIFCONDITIONPROPAGATION
 

Functions

static void propagateIfConditionsImpl (Operation *root, llvm::SmallPtrSet< Region *, 8 > &visited)
 Traverses the IR recursively (on region tree) and updates the uses of a value also as the condition of an scf.if to either true or false constants in the then and else regions. More...
 
static void propagateIfConditions (Operation *root)
 Traverses the IR recursively (on region tree) and updates the uses of a value also as the condition of an scf.if to either true or false constants in the then and `else regions. More...
 

Macro Definition Documentation

◆ GEN_PASS_DEF_SCFIFCONDITIONPROPAGATION

#define GEN_PASS_DEF_SCFIFCONDITIONPROPAGATION

Definition at line 21 of file IfConditionPropagation.cpp.

Function Documentation

◆ propagateIfConditions()

static void propagateIfConditions ( Operation root)
static

Traverses the IR recursively (on region tree) and updates the uses of a value also as the condition of an scf.if to either true or false constants in the then and `else regions.

Definition at line 87 of file IfConditionPropagation.cpp.

References propagateIfConditionsImpl().

◆ propagateIfConditionsImpl()

static void propagateIfConditionsImpl ( Operation root,
llvm::SmallPtrSet< Region *, 8 > &  visited 
)
static

Traverses the IR recursively (on region tree) and updates the uses of a value also as the condition of an scf.if to either true or false constants in the then and else regions.

This is done as a single post-order sweep over the IR (withoutwalk`) for efficiency reasons. While traversing, the function maintains the set of visited regions to quickly identify whether the value belong to a region that is known to be nested in the then or else branch of a specific loop.

Definition at line 32 of file IfConditionPropagation.cpp.

References mlir::arith::ConstantIntOp::create(), mlir::Operation::erase(), mlir::Value::getDefiningOp(), mlir::Operation::getRegions(), and mlir::Value::getUses().

Referenced by propagateIfConditions().