On 9/22/2021 12:41 PM, Aldy Hernandez wrote:
I've been pulling state from across the forward jump threader into the jt_state class, but it it still didn't feel right. The ultimate goal was to keep track of candidate threading paths so that the simplifier could simplify statements with the path as context. This patch completes the transition, while cleaning up a lot of things in the process. I've revamped both state and the simplifier such that a base state class contains only the blocks as they're registered, and any pass specific knowledge is where it belongs... in the pass. This allows VRP to keep its const and copies business, and DOM to keep this as well as its evrp client. This makes the threader cleaner, as it will now have no knowledge of either const/copies or evrp. This also paves the wave for the upcoming hybrid threader, which will just derive the state class and provide almost nothing, since the ranger doesn't need to register any equivalences or ranges as it folds. There is some code duplication in the simplifier, since both the DOM and VRP clients use a vr_values based simplifier, but this is temporary as the VRP client is about to be replaced with a hybrid ranger. For a better view of what this patch achieves, here are the base classes: class jt_state { public: virtual ~jt_state () { } virtual void push (edge); virtual void pop (); virtual void register_equiv (tree dest, tree src, bool update_range = false); virtual void register_equivs_edge (edge e); virtual void register_equivs_stmt (gimple *, basic_block, class jt_simplifier *); virtual void record_ranges_from_stmt (gimple *stmt, bool temporary); void get_path (vec<basic_block> &); void append_path (basic_block); void dump (FILE *); void debug (); private: auto_vec<basic_block> m_blocks; }; class jt_simplifier { public: virtual ~jt_simplifier () { } virtual tree simplify (gimple *, gimple *, basic_block, jt_state *) = 0; }; There are no functional changes. OK pending tests? p.s. It's sad that this is starting to look clean, just in time to get wiped out.
Sometimes you have to get it to this state so that it can get zapped.
gcc/ChangeLog: * tree-ssa-dom.c (class dom_jump_threader_simplifier): Rename... (class dom_jt_state): ...this and provide virtual overrides. (dom_jt_state::register_equiv): New. (class dom_jt_simplifier): Rename from dom_jump_threader_simplifier. (dom_jump_threader_simplifier::simplify): Rename... (dom_jt_simplifier::simplify): ...to this. (pass_dominator::execute): Use dom_jt_simplifier and dom_jt_state. * tree-ssa-threadedge.c (jump_threader::jump_threader): Clean-up. (jt_state::register_equivs_stmt): Abstract out... (jump_threader::record_temporary_equivalences_from_stmts_at_dest): ...from here. (jump_threader::thread_around_empty_blocks): Update state. (jump_threader::thread_through_normal_block): Same. (jt_state::jt_state): Remove. (jt_state::push): Remove pass specific bits. Keep block vector updated. (jt_state::append_path): New. (jt_state::pop): Remove pass specific bits. (jt_state::register_equiv): Same. (jt_state::record_ranges_from_stmt): Same. (jt_state::register_equivs_on_edge): Same. Rename... (jt_state::register_equivs_edge): ...to this. (jt_state::dump): New. (jt_state::debug): New. (jump_threader_simplifier::simplify): Remove. (jt_state::get_path): New. * tree-ssa-threadedge.h (class jt_simplifier): Make into a base class. Expose common functionality as virtual methods. (class jump_threader_simplifier): Same. Rename... (class jt_simplifier): ...to this. * tree-vrp.c (class vrp_jump_threader_simplifier): Rename... (class vrp_jt_simplifier): ...to this. Provide pass specific overrides. (class vrp_jt_state): New. (vrp_jump_threader_simplifier::simplify): Rename... (vrp_jt_simplifier::simplify): ...to this. Inline code from what used to be the base class. (vrp_jump_threader::vrp_jump_threader): Use vrp_jt_state and vrp_jt_simplifier.
OK jeff