Go to the documentation of this file. 1 #ifndef HALIDE_SIMPLIFY_VISITORS_H
2 #define HALIDE_SIMPLIFY_VISITORS_H
18 #define LOG_EXPR_MUTATIONS 0
19 #define LOG_STMT_MUTATIONS 0
26 #define EVAL_IN_LAMBDA(x) (([&]() HALIDE_NEVER_INLINE { return (x); })())
35 }
else if ((a > 0) == (b > 0)) {
112 #if (LOG_EXPR_MUTATIONS || LOG_STMT_MUTATIONS)
113 static int debug_indent;
116 #if LOG_EXPR_MUTATIONS
118 const std::string spaces(debug_indent,
' ');
119 debug(1) << spaces <<
"Simplifying Expr: " << e <<
"\n";
125 << spaces <<
"Before: " << e <<
"\n"
126 << spaces <<
"After: " << new_e <<
"\n";
140 #if LOG_STMT_MUTATIONS
142 const std::string spaces(debug_indent,
' ');
143 debug(1) << spaces <<
"Simplifying Stmt: " << s <<
"\n";
149 << spaces <<
"Before: " << s <<
"\n"
150 << spaces <<
"After: " << new_s <<
"\n";
242 return va->
name.compare(vb->name) > 0;
299 template<
typename T,
typename Body>
350 std::pair<std::vector<Expr>,
bool>
mutate_with_changes(
const std::vector<Expr> &old_exprs, ExprInfo *bounds);
Expr substitute_facts(const Expr &e)
Allocate a scratch area called with the given name, type, and size.
The sum of two expressions.
#define internal_assert(c)
int64_t saturating_mul(int64_t a, int64_t b)
T mod_imp(T a, T b)
Implementations of division and mod that are specific to Halide.
HALIDE_ALWAYS_INLINE bool may_simplify(const Type &t) const
void learn_lower_bound(const Variable *v, int64_t val)
Horizontally reduce a vector to a scalar or narrower vector using the given commutative and associati...
static ModulusRemainder intersect(const ModulusRemainder &a, const ModulusRemainder &b)
Is the first expression greater than or equal to the second.
ScopedFact scoped_falsehood(const Expr &fact)
Simplify(bool r, const Scope< Interval > *bi, const Scope< ModulusRemainder > *ai)
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
Floating point constants.
IRMatcher::WildConst< 0 > c0
IRNodeType node_type() const
A vector with 'lanes' elements, in which every element is 'value'.
The ratio of two expressions.
HALIDE_ALWAYS_INLINE bool is_float() const
Is this type a floating point type (float or double).
Expr visit(const IntImm *op, ExprInfo *bounds)
std::vector< const Variable * > pop_list
The statement form of a let node.
A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Le...
The actual IR nodes begin here.
Is the first expression less than or equal to the second.
Is the first expression not equal to the second.
Body simplify_let(const T *op, ExprInfo *bounds)
A pair of statements executed concurrently.
std::pair< std::vector< Expr >, bool > mutate_with_changes(const std::vector< Expr > &old_exprs, ExprInfo *bounds)
void learn_true(const Expr &fact)
A reference-counted handle to a statement node.
unsigned __INT64_TYPE__ uint64_t
Types in the halide type system.
Load a value from a named symbol if predicate is true.
Free the resources associated with the given buffer.
Allocate a multi-dimensional buffer of the given type and size.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Logical or - is at least one of the expression true.
Is the first expression equal to the second.
void intersect(const ExprInfo &other)
This defines the value of a function at a multi-dimensional location.
std::set< Expr, IRDeepCompare > truths
The greater of two values.
void found_buffer_reference(const std::string &name, size_t dimensions=0)
Scope< VarInfo > var_info
std::vector< Expr > truths
HALIDE_ALWAYS_INLINE bool no_overflow(Type t)
A let expression, like you might find in a functional language.
ModulusRemainder alignment
A linear ramp vector node.
#define HALIDE_ALWAYS_INLINE
Scope< ExprInfo > bounds_and_alignment_info
IRMatcher::WildConst< 3 > c3
HALIDE_ALWAYS_INLINE Type type() const
Get the type of this expression node.
std::vector< Expr > falsehoods
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.
Expr mutate_let_body(const Expr &e, ExprInfo *bounds)
IRMatcher::WildConst< 4 > c4
For optional debugging during codegen, use the debug class as follows:
Evaluate and discard an expression, presumably because it has some side-effect.
HALIDE_ALWAYS_INLINE bool no_overflow_int(Type t)
signed __INT64_TYPE__ int64_t
HALIDE_ALWAYS_INLINE Stmt dispatch(const Stmt &s, Args &&...args)
IRMatcher::WildConst< 1 > c1
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.
void trim_bounds_using_alignment()
A visitor/mutator capable of passing arbitrary arguments to the visit methods using CRTP and returnin...
std::vector< const Variable * > bounds_pop_list
The lesser of two values.
This node is a helpful annotation to do with permissions.
void learn_upper_bound(const Variable *v, int64_t val)
If the 'condition' is false, then evaluate and return the message, which should be a call to an error...
HALIDE_MUST_USE_RESULT bool mul_with_overflow(int bits, int64_t a, int64_t b, int64_t *result)
IRMatcher::WildConst< 2 > c2
HALIDE_ALWAYS_INLINE bool is_scalar() const
Is this type a scalar type? (lanes() == 1).
HALIDE_ALWAYS_INLINE bool should_commute(const Expr &a, const Expr &b)
bool const_float(const Expr &e, double *f)
Reinterpret value as another type, without affecting any of the bits (on little-endian systems).
HALIDE_ALWAYS_INLINE bool is_int() const
Is this type a signed integer type?
HALIDE_ALWAYS_INLINE bool no_overflow_scalar_int(Type t)
ScopedFact scoped_truth(const Expr &fact)
A fragment of Halide syntax.
void learn_false(const Expr &fact)
Represent a multi-dimensional region of a Func or an ImageParam that needs to be prefetched.
Is the first expression greater than the second.
Lock all the Store nodes in the body statement.
bool const_uint(const Expr &e, uint64_t *u)
Construct a new vector by taking elements from another sequence of vectors.
HALIDE_ALWAYS_INLINE void clear_bounds_info(ExprInfo *b)
HALIDE_ALWAYS_INLINE Expr mutate(const Expr &e, ExprInfo *b)
bool const_int(const Expr &e, int64_t *i)
Unsigned integer constants.
Expr max(const FuncRef &a, const FuncRef &b)
The result of modulus_remainder analysis.
std::set< Expr, IRDeepCompare > falsehoods
The difference of two expressions.
const T * as() const
Downcast this ir node to its actual type (e.g.
Logical and - are both expressions true.
Stmt mutate(const Stmt &s)
Logical not - true if the expression false.
Is the first expression less than the second.
IRMatcher::WildConst< 5 > c5
Stmt mutate_let_body(const Stmt &s, ExprInfo *)
The product of two expressions.
A sequence of statements to be executed in-order.
HALIDE_ALWAYS_INLINE bool same_as(const IntrusivePtr &other) const