Loading...
Searching...
No Matches
EliminateBoolVectors.h
Go to the documentation of this file.
#ifndef HALIDE_IR_ELIMINATE_BOOL_VECTORS_H
#define HALIDE_IR_ELIMINATE_BOOL_VECTORS_H
/** \file
* Method to eliminate vectors of booleans from IR.
*/
#include "Expr.h"
namespace Halide {
namespace Internal {
/** Some targets treat vectors of bools as integers of the same type that the
* boolean operation is being used to operate on. For example, instead of
* select(i1x8, u16x8, u16x8), the target would prefer to see select(u16x8,
* u16x8, u16x8), where the first argument is a vector of integers representing
* a mask. This pass converts vectors of bools to vectors of integers to meet
* this requirement. This is done by injecting intrinsics to convert bools to
* architecture-specific masks, and using a select_mask intrinsic instead of a
* Select node. This also converts any intrinsics that operate on vectorized
* conditions to a *_mask equivalent (if_then_else, require). Because the masks
* are architecture specific, they may not be stored or loaded. On Stores, the
* masks are converted to UInt(8) with a value of 0 or 1, which is our canonical
* in-memory representation of a bool. */
///@{
Stmt eliminate_bool_vectors(const Stmt &s);
Expr eliminate_bool_vectors(const Expr &s);
///@}
/** If a type is a boolean vector, find the type that it has been
* changed to by eliminate_bool_vectors. */
inline Type eliminated_bool_type(Type bool_type, Type other_type) {
if (bool_type.is_vector() && bool_type.bits() == 1) {
bool_type = bool_type.with_code(Type::Int).with_bits(other_type.bits());
}
return bool_type;
}
} // namespace Internal
} // namespace Halide
#endif
Expr.h
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt).
Halide::Internal
Definition AbstractGenerator.h:24
Halide::Internal::eliminated_bool_type
Type eliminated_bool_type(Type bool_type, Type other_type)
If a type is a boolean vector, find the type that it has been changed to by eliminate_bool_vectors.
Definition EliminateBoolVectors.h:32
Halide::Internal::eliminate_bool_vectors
Stmt eliminate_bool_vectors(const Stmt &s)
Some targets treat vectors of bools as integers of the same type that the boolean operation is being ...
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258
Halide::Internal::Stmt
A reference-counted handle to a statement node.
Definition Expr.h:427
Halide::Type
Types in the halide type system.
Definition Type.h:283
Halide::Type::Int
static const halide_type_code_t Int
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
Definition Type.h:291
Halide::Type::with_bits
Type with_bits(int new_bits) const
Return Type with same type code and lanes, but new_bits for the number of bits.
Definition Type.h:366
Halide::Type::bits
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.
Definition Type.h:349
Halide::Type::is_vector
HALIDE_ALWAYS_INLINE bool is_vector() const
Is this type a vector type?
Definition Type.h:410
Halide::Type::with_code
Type with_code(halide_type_code_t new_code) const
Return Type with same number of bits and lanes, but new_code for a type code.
Definition Type.h:360