From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id BAC4539540E3; Tue, 6 Oct 2020 13:49:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAC4539540E3 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/if-to-switch-v4)] Fix various issues. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/if-to-switch-v4 X-Git-Oldrev: 2247b390dc18dfaffa4caa4f20633d66b948da79 X-Git-Newrev: 3652bc0ebb14108321ea898d96baad6a12863176 Message-Id: <20201006134930.BAC4539540E3@sourceware.org> Date: Tue, 6 Oct 2020 13:49:30 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2020 13:49:30 -0000 https://gcc.gnu.org/g:3652bc0ebb14108321ea898d96baad6a12863176 commit 3652bc0ebb14108321ea898d96baad6a12863176 Author: Martin Liska Date: Fri Oct 2 15:30:03 2020 +0200 Fix various issues. Diff: --- gcc/common.opt | 4 ---- gcc/doc/invoke.texi | 9 --------- gcc/gimple-if-to-switch.cc | 29 ++++++++++++++++------------- gcc/opts.c | 1 - 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 337a30cdac9..3169d71cea5 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1173,10 +1173,6 @@ fconserve-stack Common Var(flag_conserve_stack) Optimization Do not perform optimizations increasing noticeably stack usage. -fconvert-if-to-switch -Common Report Var(flag_convert_if_to_switch) Optimization -Perform conversions of if-elseif chain into a switch statement. - fcprop-registers Common Report Var(flag_cprop_registers) Optimization Perform a register copy-propagation optimization pass. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d1536d8f533..25bddad361f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2654,14 +2654,6 @@ Allow conditional expressions with mismatched types in the second and third arguments. The value of such an expression is void. This option is not supported for C++. -@item -fconvert-if-to-switch -@opindex fconvert-if-to-switch -Perform conversion of an if cascade into a switch statement. -Do so if the switch can be later transformed using a jump table -or a bit test. The transformation can help to produce faster code for -the switch statement. This flag is enabled by default -at @option{-O2} and higher. - @item -flax-vector-conversions @opindex flax-vector-conversions Allow implicit conversions between vectors with differing numbers of @@ -9764,7 +9756,6 @@ also turns on the following optimization flags: -falign-labels -falign-loops @gol -fcaller-saves @gol -fcode-hoisting @gol --fconvert-if-to-switch @gol -fcrossjumping @gol -fcse-follow-jumps -fcse-skip-blocks @gol -fdelete-null-pointer-checks @gol diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc index d67099cd614..75388e54ce5 100644 --- a/gcc/gimple-if-to-switch.cc +++ b/gcc/gimple-if-to-switch.cc @@ -288,7 +288,7 @@ if_chain::record_phi_arguments (edge e) tree *v = m_phi_map.get (phi); if (v != NULL) { - if (arg != *v) + if (!operand_equal_p (arg, *v)) return false; } else @@ -494,7 +494,7 @@ extract_case_from_stmt (tree rhs1, tree rhs2, tree_code code, static void find_switch_in_bb (basic_block bb, auto_vec *all_candidates, - auto_bitmap *visited_bbs) + auto_sbitmap *visited_bbs) { if_chain *chain = new if_chain (); unsigned total_case_values = 0; @@ -668,15 +668,13 @@ find_switch_in_bb (basic_block bb, auto_vec *all_candidates, && chain->check_non_overlapping_cases () && chain->is_beneficial ()) { - expanded_location loc - = expand_location (gimple_location (chain->m_first_condition)); - if (dump_file) - { - fprintf (dump_file, "Condition chain (at %s:%d) with %d conditions " - "(%d BBs) transformed into a switch statement.\n", - loc.file, loc.line, total_case_values, - chain->m_entries.length ()); - } + location_t loc = gimple_location (chain->m_first_condition); + if (dump_enabled_p ()) + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, + dump_user_location_t::from_location_t (loc), + "Condition chain with %d conditions " + "(%d BBs) transformed into a switch statement.\n", + total_case_values, chain->m_entries.length ()); all_candidates->safe_push (chain); } @@ -713,7 +711,12 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *) { return flag_convert_if_to_switch != 0; } + virtual bool gate (function *) + { + return (jump_table_cluster::is_enabled () + || bit_test_cluster::is_enabled ()); + } + virtual unsigned int execute (function *); }; // class pass_if_to_switch @@ -725,7 +728,7 @@ pass_if_to_switch::execute (function *fun) auto_vec all_candidates; auto_vec worklist; - auto_bitmap visited_bbs; + auto_sbitmap visited_bbs (last_basic_block_for_fn (fun)); worklist.safe_push (ENTRY_BLOCK_PTR_FOR_FN (fun)); while (!worklist.is_empty ()) diff --git a/gcc/opts.c b/gcc/opts.c index 03baf758283..3bda59afced 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -510,7 +510,6 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_CHEAP }, { OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 }, - { OPT_LEVELS_2_PLUS, OPT_fconvert_if_to_switch, NULL, 1 }, /* -O2 and above optimizations, but not -Os or -Og. */ { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_functions, NULL, 1 },