Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
CSE.h
Go to the documentation of this file.
1#ifndef HALIDE_INTERNAL_CSE_H
2#define HALIDE_INTERNAL_CSE_H
3
4/** \file
5 * Defines a pass for introducing let expressions to wrap common sub-expressions. */
6
7#include "Expr.h"
8
9namespace Halide {
10namespace Internal {
11
12/** Replace each common sub-expression in the argument with a
13 * variable, and wrap the resulting expr in a let statement giving a
14 * value to that variable.
15 *
16 * This is important to do within Halide (instead of punting to llvm),
17 * because exprs that come in from the front-end are small when
18 * considered as a graph, but combinatorially large when considered as
19 * a tree. For an example of a such a case, see
20 * test/code_explosion.cpp
21 *
22 * The last parameter determines whether all common subexpressions are
23 * lifted, or only those that the simplifier would not subsitute back
24 * in (e.g. addition of a constant).
25 */
26Expr common_subexpression_elimination(const Expr &, bool lift_all = false);
27
28/** Do common-subexpression-elimination on each expression in a
29 * statement. Does not introduce let statements. */
30Stmt common_subexpression_elimination(const Stmt &, bool lift_all = false);
31
32void cse_test();
33
34} // namespace Internal
35} // namespace Halide
36
37#endif
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt)
Expr common_subexpression_elimination(const Expr &, bool lift_all=false)
Replace each common sub-expression in the argument with a variable, and wrap the resulting expr in a ...
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
A fragment of Halide syntax.
Definition Expr.h:258
A reference-counted handle to a statement node.
Definition Expr.h:427