-
- Downloads
c++: Use two levels of caching in satisfy_atom
This improves the effectiveness of caching in satisfy_atom by querying the cache again after we've instantiated the atom's parameter mapping. Before instantiating its mapping, the identity of an (atom,args) pair within the satisfaction cache is determined by idiosyncratic things like the level and index of each template parameter used in targets of the parameter mapping. For example, the associated constraints of foo in template <class T> concept range = range_v<T>; template <class U, class V> void foo () requires range<U> && range<V>; are range_v<T> (with mapping T -> U) /\ range_v<T> (with mapping T -> V). If during satisfaction the template arguments supplied for U and V are the same, then the satisfaction value of these two atoms will be the same (despite their uninstantiated parameter mappings being different). But sat_cache doesn't see this because it compares the uninstantiated parameter mapping and the supplied template arguments of sat_entry's independently. So satisy_atom on this latter atom will end up fully evaluating it instead of reusing the satisfaction value of the former. But there is a point when the two atoms do look the same to sat_cache, and that's after instantiating their parameter mappings. By querying the cache again at this point, we can avoid substituting the same instantiated parameter mapping into the same expression a second time around. With this patch, compile time and memory usage for the cmcstl2 test test/algorithm/set_symmetric_diference4.cpp drops from 11s/1.4GB to 8.5s/1.2GB with an --enable-checking=release compiler. gcc/cp/ChangeLog: * cp-tree.h (ATOMIC_CONSTR_MAP_INSTANTIATED_P): Define this flag for ATOMIC_CONSTRs. * constraint.cc (sat_hasher::hash): Use hash_atomic_constraint if the flag is set, otherwise keep using a pointer hash. (sat_hasher::equal): Return false if the flag's setting differs on two atoms. Call atomic_constraints_identical_p if the flag is set, otherwise keep using a pointer equality test. (satisfy_atom): After instantiating the parameter mapping, form another ATOMIC_CONSTR using the instantiated mapping and query the cache again. Cache the satisfaction value of both atoms. (diagnose_atomic_constraint): Simplify now that the supplied atom has an instantiated mapping.
Loading
Please register or sign in to comment