Template Function sequant::opt::eliminate_common_subexpressions(VectorLike&, std::size_t, std::size_t, const Transformer&, const CSEOptions<std::ranges::range_value_t<VectorLike>>)¶
Defined in File common_subexpression_elimination.hpp
Function Documentation¶
-
template<std::ranges::range VectorLike, std::regular_invocable<ExprPtr> Transformer, bool force_hash_collisions = false>
std::vector<std::size_t> sequant::opt::eliminate_common_subexpressions(VectorLike &expr_trees, std::size_t expr_begin, std::size_t expr_end, const Transformer &expr_to_tree, const CSEOptions<std::ranges::range_value_t<VectorLike>> opts = {})¶ Takes the range of expression trees and performs common subexpression elimination on them. Evaluation trees for intermediates are inserted into the given container as needed.
Note
Every intermediate gets its own name. Once the final order of evaluation is known, opt::recycle_intermediate_names (see name_recycling.hpp) can be used to reuse names of intermediates that are no longer needed.
- Parameters:
expr_trees – Container (vector-like) of evaluation trees
expr_to_tree – Functor that can convert ExprPtr and ResultExpr objects into suitable evaluation trees
filter_predicate – A predicate to filter out subexpressions that shall not be eliminated
- Returns:
The positions of the inserted intermediate definitions