gcc/gcc/gimple-ssa-store-merging.cc

5649 lines
172 KiB
C++
Raw Permalink Normal View History

/* GIMPLE store merging and byte swapping passes.
2022-01-03 10:42:10 +01:00
Copyright (C) 2009-2022 Free Software Foundation, Inc.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
Contributed by ARM Ltd.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* The purpose of the store merging pass is to combine multiple memory stores
of constant values, values loaded from memory, bitwise operations on those,
or bit-field values, to consecutive locations, into fewer wider stores.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
For example, if we have a sequence peforming four byte stores to
consecutive memory locations:
[p ] := imm1;
[p + 1B] := imm2;
[p + 2B] := imm3;
[p + 3B] := imm4;
we can transform this into a single 4-byte store if the target supports it:
[p] := imm1:imm2:imm3:imm4 concatenated according to endianness.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
Or:
[p ] := [q ];
[p + 1B] := [q + 1B];
[p + 2B] := [q + 2B];
[p + 3B] := [q + 3B];
if there is no overlap can be transformed into a single 4-byte
load followed by single 4-byte store.
Or:
[p ] := [q ] ^ imm1;
[p + 1B] := [q + 1B] ^ imm2;
[p + 2B] := [q + 2B] ^ imm3;
[p + 3B] := [q + 3B] ^ imm4;
if there is no overlap can be transformed into a single 4-byte
load, xored with imm1:imm2:imm3:imm4 and stored using a single 4-byte store.
Or:
[p:1 ] := imm;
[p:31] := val & 0x7FFFFFFF;
we can transform this into a single 4-byte store if the target supports it:
[p] := imm:(val & 0x7FFFFFFF) concatenated according to endianness.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
The algorithm is applied to each basic block in three phases:
1) Scan through the basic block and record assignments to destinations
that can be expressed as a store to memory of a certain size at a certain
bit offset from base expressions we can handle. For bit-fields we also
record the surrounding bit region, i.e. bits that could be stored in
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
a read-modify-write operation when storing the bit-field. Record store
chains to different bases in a hash_map (m_stores) and make sure to
Fix up duplicated duplicated words mostly in comments In the r10-7197-gbae7b38cf8a21e068ad5c0bab089dedb78af3346 commit I've noticed duplicated word in a message, which lead me to grep for those and we have a tons of them. I've used grep -v 'long long\|optab optab\|template template\|double double' *.[chS] */*.[chS] *.def config/*/* 2>/dev/null | grep ' \([a-zA-Z]\+\) \1 ' Note, the command will not detect the doubled words at the start or end of line or when one of the words is at the end of line and the next one at the start of another one. Some of it is fairly obvious, e.g. all the "the the" cases which is something I've posted and committed patch for already e.g. in 2016, other cases are often valid, e.g. "that that" seems to look mostly ok to me. Some cases are quite hard to figure out, I've left out some of them from the patch (e.g. "and and" in some cases isn't talking about bitwise/logical and and so looks incorrect, but in other cases it is talking about those operations). In most cases the right solution seems to be to remove one of the duplicated words, but not always. I think most important are the ones with user visible messages (in the patch 3 of the first 4 hunks), the rest is just comments (and internal documentation; for that see the doc/tm.texi changes). 2020-03-17 Jakub Jelinek <jakub@redhat.com> * lra-spills.c (remove_pseudos): Fix up duplicated word issue in a dump message. * tree-sra.c (create_access_replacement): Fix up duplicated word issue in a comment. * read-rtl-function.c (find_param_by_name, function_reader::parse_enum_value, function_reader::get_insn_by_uid): Likewise. * spellcheck.c (get_edit_distance_cutoff): Likewise. * tree-data-ref.c (create_ifn_alias_checks): Likewise. * tree.def (SWITCH_EXPR): Likewise. * selftest.c (assert_str_contains): Likewise. * ipa-param-manipulation.h (class ipa_param_body_adjustments): Likewise. * tree-ssa-math-opts.c (convert_expand_mult_copysign): Likewise. * tree-ssa-loop-split.c (find_vdef_in_loop): Likewise. * langhooks.h (struct lang_hooks_for_decls): Likewise. * ipa-prop.h (struct ipa_param_descriptor): Likewise. * tree-ssa-strlen.c (handle_builtin_string_cmp, handle_store): Likewise. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Likewise. * tree-ssa-reassoc.c (reassociate_bb): Likewise. * tree.c (component_ref_size): Likewise. * hsa-common.c (hsa_init_compilation_unit_data): Likewise. * gimple-ssa-sprintf.c (get_string_length, format_string, format_directive): Likewise. * omp-grid.c (grid_process_kernel_body_copy): Likewise. * input.c (string_concat_db::get_string_concatenation, test_lexer_string_locations_ucn4): Likewise. * cfgexpand.c (pass_expand::execute): Likewise. * gimple-ssa-warn-restrict.c (builtin_memref::offset_out_of_bounds, maybe_diag_overlap): Likewise. * rtl.c (RTX_CODE_HWINT_P_1): Likewise. * shrink-wrap.c (spread_components): Likewise. * tree-ssa-dse.c (initialize_ao_ref_for_dse, valid_ao_ref_for_dse): Likewise. * tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds): Likewise. * dwarf2out.c (dwarf2out_early_finish): Likewise. * gimple-ssa-store-merging.c: Likewise. * ira-costs.c (record_operand_costs): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * target.def (dispatch): Likewise. (validate_dims, gen_ccmp_first): Fix up duplicated word issue in documentation text. * doc/tm.texi: Regenerated. * config/i386/x86-tune.def (X86_TUNE_PARTIAL_FLAG_REG_STALL): Fix up duplicated word issue in a comment. * config/i386/i386.c (ix86_test_loading_unspec): Likewise. * config/i386/i386-features.c (remove_partial_avx_dependency): Likewise. * config/msp430/msp430.c (msp430_select_section): Likewise. * config/gcn/gcn-run.c (load_image): Likewise. * config/aarch64/aarch64-sve.md (sve_ld1r<mode>): Likewise. * config/aarch64/aarch64.c (aarch64_gen_adjusted_ldpstp): Likewise. * config/aarch64/falkor-tag-collision-avoidance.c (single_dest_per_chain): Likewise. * config/nvptx/nvptx.c (nvptx_record_fndecl): Likewise. * config/fr30/fr30.c (fr30_arg_partial_bytes): Likewise. * config/rs6000/rs6000-string.c (expand_cmp_vec_sequence): Likewise. * config/rs6000/rs6000-p8swap.c (replace_swapped_load_constant): Likewise. * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/rs6000/rs6000-logue.c (rs6000_emit_probe_stack_range_stack_clash): Likewise. * config/nds32/nds32-md-auxiliary.c (nds32_split_ashiftdi3): Likewise. Fix various other issues in the comment. c-family/ * c-common.c (resolve_overloaded_builtin): Fix up duplicated word issue in a diagnostic message. cp/ * pt.c (tsubst): Fix up duplicated word issue in a diagnostic message. (lookup_template_class_1, tsubst_expr): Fix up duplicated word issue in a comment. * parser.c (cp_parser_statement, cp_parser_linkage_specification, cp_parser_placeholder_type_specifier, cp_parser_constraint_requires_parens): Likewise. * name-lookup.c (suggest_alternative_in_explicit_scope): Likewise. fortran/ * array.c (gfc_check_iter_variable): Fix up duplicated word issue in a comment. * arith.c (gfc_arith_concat): Likewise. * resolve.c (gfc_resolve_ref): Likewise. * frontend-passes.c (matmul_lhs_realloc): Likewise. * module.c (gfc_match_submodule, load_needed): Likewise. * trans-expr.c (gfc_init_se): Likewise.
2020-03-17 13:52:19 +01:00
terminate such chains when appropriate (for example when the stored
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
values get used subsequently).
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
These stores can be a result of structure element initializers, array stores
etc. A store_immediate_info object is recorded for every such store.
Record as many such assignments to a single base as possible until a
statement that interferes with the store sequence is encountered.
Each store has up to 2 operands, which can be a either constant, a memory
load or an SSA name, from which the value to be stored can be computed.
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
At most one of the operands can be a constant. The operands are recorded
in store_operand_info struct.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
2) Analyze the chains of stores recorded in phase 1) (i.e. the vector of
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
store_immediate_info objects) and coalesce contiguous stores into
merged_store_group objects. For bit-field stores, we don't need to
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
require the stores to be contiguous, just their surrounding bit regions
have to be contiguous. If the expression being stored is different
between adjacent stores, such as one store storing a constant and
following storing a value loaded from memory, or if the loaded memory
objects are not adjacent, a new merged_store_group is created as well.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
For example, given the stores:
[p ] := 0;
[p + 1B] := 1;
[p + 3B] := 0;
[p + 4B] := 1;
[p + 5B] := 0;
[p + 6B] := 0;
This phase would produce two merged_store_group objects, one recording the
two bytes stored in the memory region [p : p + 1] and another
recording the four bytes stored in the memory region [p + 3 : p + 6].
3) The merged_store_group objects produced in phase 2) are processed
to generate the sequence of wider stores that set the contiguous memory
regions to the sequence of bytes that correspond to it. This may emit
multiple stores per store group to handle contiguous stores that are not
of a size that is a power of 2. For example it can try to emit a 40-bit
store as a 32-bit store followed by an 8-bit store.
We try to emit as wide stores as we can while respecting STRICT_ALIGNMENT
or TARGET_SLOW_UNALIGNED_ACCESS settings.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
Note on endianness and example:
Consider 2 contiguous 16-bit stores followed by 2 contiguous 8-bit stores:
[p ] := 0x1234;
[p + 2B] := 0x5678;
[p + 4B] := 0xab;
[p + 5B] := 0xcd;
The memory layout for little-endian (LE) and big-endian (BE) must be:
p |LE|BE|
---------
0 |34|12|
1 |12|34|
2 |78|56|
3 |56|78|
4 |ab|ab|
5 |cd|cd|
To merge these into a single 48-bit merged value 'val' in phase 2)
on little-endian we insert stores to higher (consecutive) bitpositions
into the most significant bits of the merged value.
The final merged value would be: 0xcdab56781234
For big-endian we insert stores to higher bitpositions into the least
significant bits of the merged value.
The final merged value would be: 0x12345678abcd
Then, in phase 3), we want to emit this 48-bit value as a 32-bit store
followed by a 16-bit store. Again, we must consider endianness when
breaking down the 48-bit value 'val' computed above.
For little endian we emit:
[p] (32-bit) := 0x56781234; // val & 0x0000ffffffff;
[p + 4B] (16-bit) := 0xcdab; // (val & 0xffff00000000) >> 32;
Whereas for big-endian we emit:
[p] (32-bit) := 0x12345678; // (val & 0xffffffff0000) >> 16;
[p + 4B] (16-bit) := 0xabcd; // val & 0x00000000ffff; */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "builtins.h"
#include "fold-const.h"
#include "tree-pass.h"
#include "ssa.h"
#include "gimple-pretty-print.h"
#include "alias.h"
#include "fold-const.h"
#include "print-tree.h"
#include "tree-hash-traits.h"
#include "gimple-iterator.h"
#include "gimplify.h"
#include "gimple-fold.h"
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
#include "stor-layout.h"
#include "timevar.h"
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
#include "cfganal.h"
#include "cfgcleanup.h"
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
#include "tree-cfg.h"
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
#include "except.h"
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
#include "tree-eh.h"
#include "target.h"
#include "gimplify-me.h"
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
#include "rtl.h"
#include "expr.h" /* For get_bit_range. */
#include "optabs-tree.h"
#include "dbgcnt.h"
#include "selftest.h"
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* The maximum size (in bits) of the stores this pass should generate. */
#define MAX_STORE_BITSIZE (BITS_PER_WORD)
#define MAX_STORE_BYTES (MAX_STORE_BITSIZE / BITS_PER_UNIT)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Limit to bound the number of aliasing checks for loads with the same
vuse as the corresponding store. */
#define MAX_STORE_ALIAS_CHECKS 64
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
namespace {
struct bswap_stat
{
/* Number of hand-written 16-bit nop / bswaps found. */
int found_16bit;
/* Number of hand-written 32-bit nop / bswaps found. */
int found_32bit;
/* Number of hand-written 64-bit nop / bswaps found. */
int found_64bit;
} nop_stats, bswap_stats;
/* A symbolic number structure is used to detect byte permutation and selection
patterns of a source. To achieve that, its field N contains an artificial
number consisting of BITS_PER_MARKER sized markers tracking where does each
byte come from in the source:
0 - target byte has the value 0
FF - target byte has an unknown value (eg. due to sign extension)
1..size - marker value is the byte index in the source (0 for lsb).
To detect permutations on memory sources (arrays and structures), a symbolic
number is also associated:
- a base address BASE_ADDR and an OFFSET giving the address of the source;
- a range which gives the difference between the highest and lowest accessed
memory location to make such a symbolic number;
- the address SRC of the source element of lowest address as a convenience
to easily get BASE_ADDR + offset + lowest bytepos;
- number of expressions N_OPS bitwise ored together to represent
approximate cost of the computation.
Note 1: the range is different from size as size reflects the size of the
type of the current expression. For instance, for an array char a[],
(short) a[0] | (short) a[3] would have a size of 2 but a range of 4 while
(short) a[0] | ((short) a[0] << 1) would still have a size of 2 but this
time a range of 1.
Note 2: for non-memory sources, range holds the same value as size.
Note 3: SRC points to the SSA_NAME in case of non-memory source. */
struct symbolic_number {
uint64_t n;
tree type;
tree base_addr;
tree offset;
poly_int64_pod bytepos;
tree src;
tree alias_set;
tree vuse;
unsigned HOST_WIDE_INT range;
int n_ops;
};
#define BITS_PER_MARKER 8
#define MARKER_MASK ((1 << BITS_PER_MARKER) - 1)
#define MARKER_BYTE_UNKNOWN MARKER_MASK
#define HEAD_MARKER(n, size) \
((n) & ((uint64_t) MARKER_MASK << (((size) - 1) * BITS_PER_MARKER)))
/* The number which the find_bswap_or_nop_1 result should match in
order to have a nop. The number is masked according to the size of
the symbolic number before using it. */
#define CMPNOP (sizeof (int64_t) < 8 ? 0 : \
(uint64_t)0x08070605 << 32 | 0x04030201)
/* The number which the find_bswap_or_nop_1 result should match in
order to have a byte swap. The number is masked according to the
size of the symbolic number before using it. */
#define CMPXCHG (sizeof (int64_t) < 8 ? 0 : \
(uint64_t)0x01020304 << 32 | 0x05060708)
/* Perform a SHIFT or ROTATE operation by COUNT bits on symbolic
number N. Return false if the requested operation is not permitted
on a symbolic number. */
inline bool
do_shift_rotate (enum tree_code code,
struct symbolic_number *n,
int count)
{
int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
uint64_t head_marker;
if (count < 0
|| count >= TYPE_PRECISION (n->type)
|| count % BITS_PER_UNIT != 0)
return false;
count = (count / BITS_PER_UNIT) * BITS_PER_MARKER;
/* Zero out the extra bits of N in order to avoid them being shifted
into the significant bits. */
if (size < 64 / BITS_PER_MARKER)
n->n &= ((uint64_t) 1 << (size * BITS_PER_MARKER)) - 1;
switch (code)
{
case LSHIFT_EXPR:
n->n <<= count;
break;
case RSHIFT_EXPR:
head_marker = HEAD_MARKER (n->n, size);
n->n >>= count;
/* Arithmetic shift of signed type: result is dependent on the value. */
if (!TYPE_UNSIGNED (n->type) && head_marker)
for (i = 0; i < count / BITS_PER_MARKER; i++)
n->n |= (uint64_t) MARKER_BYTE_UNKNOWN
<< ((size - 1 - i) * BITS_PER_MARKER);
break;
case LROTATE_EXPR:
n->n = (n->n << count) | (n->n >> ((size * BITS_PER_MARKER) - count));
break;
case RROTATE_EXPR:
n->n = (n->n >> count) | (n->n << ((size * BITS_PER_MARKER) - count));
break;
default:
return false;
}
/* Zero unused bits for size. */
if (size < 64 / BITS_PER_MARKER)
n->n &= ((uint64_t) 1 << (size * BITS_PER_MARKER)) - 1;
return true;
}
/* Perform sanity checking for the symbolic number N and the gimple
statement STMT. */
inline bool
verify_symbolic_number_p (struct symbolic_number *n, gimple *stmt)
{
tree lhs_type;
lhs_type = TREE_TYPE (gimple_get_lhs (stmt));
if (TREE_CODE (lhs_type) != INTEGER_TYPE
&& TREE_CODE (lhs_type) != ENUMERAL_TYPE)
return false;
if (TYPE_PRECISION (lhs_type) != TYPE_PRECISION (n->type))
return false;
return true;
}
/* Initialize the symbolic number N for the bswap pass from the base element
SRC manipulated by the bitwise OR expression. */
bool
init_symbolic_number (struct symbolic_number *n, tree src)
{
int size;
if (!INTEGRAL_TYPE_P (TREE_TYPE (src)) && !POINTER_TYPE_P (TREE_TYPE (src)))
return false;
n->base_addr = n->offset = n->alias_set = n->vuse = NULL_TREE;
n->src = src;
/* Set up the symbolic number N by setting each byte to a value between 1 and
the byte size of rhs1. The highest order byte is set to n->size and the
lowest order byte to 1. */
n->type = TREE_TYPE (src);
size = TYPE_PRECISION (n->type);
if (size % BITS_PER_UNIT != 0)
return false;
size /= BITS_PER_UNIT;
if (size > 64 / BITS_PER_MARKER)
return false;
n->range = size;
n->n = CMPNOP;
n->n_ops = 1;
if (size < 64 / BITS_PER_MARKER)
n->n &= ((uint64_t) 1 << (size * BITS_PER_MARKER)) - 1;
return true;
}
/* Check if STMT might be a byte swap or a nop from a memory source and returns
the answer. If so, REF is that memory source and the base of the memory area
accessed and the offset of the access from that base are recorded in N. */
bool
find_bswap_or_nop_load (gimple *stmt, tree ref, struct symbolic_number *n)
{
/* Leaf node is an array or component ref. Memorize its base and
offset from base to compare to other such leaf node. */
poly_int: get_inner_reference & co. This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255914
2017-12-21 07:57:41 +01:00
poly_int64 bitsize, bitpos, bytepos;
machine_mode mode;
int unsignedp, reversep, volatilep;
tree offset, base_addr;
/* Not prepared to handle PDP endian. */
if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
return false;
if (!gimple_assign_load_p (stmt) || gimple_has_volatile_ops (stmt))
return false;
base_addr = get_inner_reference (ref, &bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (TREE_CODE (base_addr) == TARGET_MEM_REF)
/* Do not rewrite TARGET_MEM_REF. */
return false;
else if (TREE_CODE (base_addr) == MEM_REF)
{
poly_offset_int bit_offset = 0;
tree off = TREE_OPERAND (base_addr, 1);
if (!integer_zerop (off))
{
poly_offset_int boff = mem_ref_offset (base_addr);
boff <<= LOG2_BITS_PER_UNIT;
bit_offset += boff;
}
base_addr = TREE_OPERAND (base_addr, 0);
/* Avoid returning a negative bitpos as this may wreak havoc later. */
if (maybe_lt (bit_offset, 0))
{
tree byte_offset = wide_int_to_tree
(sizetype, bits_to_bytes_round_down (bit_offset));
bit_offset = num_trailing_bits (bit_offset);
if (offset)
offset = size_binop (PLUS_EXPR, offset, byte_offset);
else
offset = byte_offset;
}
bitpos += bit_offset.force_shwi ();
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else
base_addr = build_fold_addr_expr (base_addr);
poly_int: get_inner_reference & co. This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255914
2017-12-21 07:57:41 +01:00
if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos))
return false;
poly_int: get_inner_reference & co. This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255914
2017-12-21 07:57:41 +01:00
if (!multiple_p (bitsize, BITS_PER_UNIT))
return false;
if (reversep)
return false;
if (!init_symbolic_number (n, ref))
return false;
n->base_addr = base_addr;
n->offset = offset;
poly_int: get_inner_reference & co. This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255914
2017-12-21 07:57:41 +01:00
n->bytepos = bytepos;
n->alias_set = reference_alias_ptr_type (ref);
n->vuse = gimple_vuse (stmt);
return true;
}
bswap: Fix up symbolic merging for xor and plus [PR103376] On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote: > This patch implements PR tree-optimization/103345 to merge adjacent > loads when combined with addition or bitwise xor. The current code > in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior, > so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in > the same way at BIT_IOR_EXPR. Unfortunately they aren't exactly the same. They work the same if always at least one operand (or corresponding byte in it) is known to be 0, 0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x, so perform_symbolic_merge has been accepting either that at least one of the bytes is 0 or that both are the same, but that is wrong for ^ and +. The following patch fixes that by passing through the code of binary operation and allowing non-zero masked1 == masked2 through only for BIT_IOR_EXPR. Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. 2021-11-24 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1 or masked2 is 0. (find_bswap_or_nop_1, find_bswap_or_nop, imm_store_chain_info::try_coalesce_bswap): Adjust perform_symbolic_merge callers. * gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
/* Compute the symbolic number N representing the result of a bitwise OR,
bitwise XOR or plus on 2 symbolic number N1 and N2 whose source statements
are respectively SOURCE_STMT1 and SOURCE_STMT2. CODE is the operation. */
gimple *
perform_symbolic_merge (gimple *source_stmt1, struct symbolic_number *n1,
gimple *source_stmt2, struct symbolic_number *n2,
bswap: Fix up symbolic merging for xor and plus [PR103376] On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote: > This patch implements PR tree-optimization/103345 to merge adjacent > loads when combined with addition or bitwise xor. The current code > in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior, > so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in > the same way at BIT_IOR_EXPR. Unfortunately they aren't exactly the same. They work the same if always at least one operand (or corresponding byte in it) is known to be 0, 0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x, so perform_symbolic_merge has been accepting either that at least one of the bytes is 0 or that both are the same, but that is wrong for ^ and +. The following patch fixes that by passing through the code of binary operation and allowing non-zero masked1 == masked2 through only for BIT_IOR_EXPR. Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. 2021-11-24 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1 or masked2 is 0. (find_bswap_or_nop_1, find_bswap_or_nop, imm_store_chain_info::try_coalesce_bswap): Adjust perform_symbolic_merge callers. * gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
struct symbolic_number *n, enum tree_code code)
{
int i, size;
uint64_t mask;
gimple *source_stmt;
struct symbolic_number *n_start;
tree rhs1 = gimple_assign_rhs1 (source_stmt1);
if (TREE_CODE (rhs1) == BIT_FIELD_REF
&& TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
rhs1 = TREE_OPERAND (rhs1, 0);
tree rhs2 = gimple_assign_rhs1 (source_stmt2);
if (TREE_CODE (rhs2) == BIT_FIELD_REF
&& TREE_CODE (TREE_OPERAND (rhs2, 0)) == SSA_NAME)
rhs2 = TREE_OPERAND (rhs2, 0);
/* Sources are different, cancel bswap if they are not memory location with
the same base (array, structure, ...). */
if (rhs1 != rhs2)
{
uint64_t inc;
HOST_WIDE_INT start1, start2, start_sub, end_sub, end1, end2, end;
struct symbolic_number *toinc_n_ptr, *n_end;
basic_block bb1, bb2;
if (!n1->base_addr || !n2->base_addr
|| !operand_equal_p (n1->base_addr, n2->base_addr, 0))
return NULL;
if (!n1->offset != !n2->offset
|| (n1->offset && !operand_equal_p (n1->offset, n2->offset, 0)))
return NULL;
start1 = 0;
if (!(n2->bytepos - n1->bytepos).is_constant (&start2))
return NULL;
if (start1 < start2)
{
n_start = n1;
start_sub = start2 - start1;
}
else
{
n_start = n2;
start_sub = start1 - start2;
}
bb1 = gimple_bb (source_stmt1);
bb2 = gimple_bb (source_stmt2);
if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
source_stmt = source_stmt1;
else
source_stmt = source_stmt2;
/* Find the highest address at which a load is performed and
compute related info. */
end1 = start1 + (n1->range - 1);
end2 = start2 + (n2->range - 1);
if (end1 < end2)
{
end = end2;
end_sub = end2 - end1;
}
else
{
end = end1;
end_sub = end1 - end2;
}
n_end = (end2 > end1) ? n2 : n1;
/* Find symbolic number whose lsb is the most significant. */
if (BYTES_BIG_ENDIAN)
toinc_n_ptr = (n_end == n1) ? n2 : n1;
else
toinc_n_ptr = (n_start == n1) ? n2 : n1;
n->range = end - MIN (start1, start2) + 1;
/* Check that the range of memory covered can be represented by
a symbolic number. */
if (n->range > 64 / BITS_PER_MARKER)
return NULL;
/* Reinterpret byte marks in symbolic number holding the value of
bigger weight according to target endianness. */
inc = BYTES_BIG_ENDIAN ? end_sub : start_sub;
size = TYPE_PRECISION (n1->type) / BITS_PER_UNIT;
for (i = 0; i < size; i++, inc <<= BITS_PER_MARKER)
{
unsigned marker
= (toinc_n_ptr->n >> (i * BITS_PER_MARKER)) & MARKER_MASK;
if (marker && marker != MARKER_BYTE_UNKNOWN)
toinc_n_ptr->n += inc;
}
}
else
{
n->range = n1->range;
n_start = n1;
source_stmt = source_stmt1;
}
if (!n1->alias_set
|| alias_ptr_types_compatible_p (n1->alias_set, n2->alias_set))
n->alias_set = n1->alias_set;
else
n->alias_set = ptr_type_node;
n->vuse = n_start->vuse;
n->base_addr = n_start->base_addr;
n->offset = n_start->offset;
n->src = n_start->src;
n->bytepos = n_start->bytepos;
n->type = n_start->type;
size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
bswap: Improve perform_symbolic_merge [PR103376] Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. This patch just punts on plus if both corresponding bytes are non-zero, otherwise implements the above. 2021-11-25 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): For BIT_IOR_EXPR, if masked1 && masked2 && masked1 != masked2, don't punt, but set the corresponding result byte to MARKER_BYTE_UNKNOWN. For BIT_XOR_EXPR similarly and if masked1 == masked2 and the byte isn't MARKER_BYTE_UNKNOWN, set the corresponding result byte to 0. * gcc.dg/optimize-bswapsi-7.c: New test.
2021-11-25 10:38:33 +01:00
uint64_t res_n = n1->n | n2->n;
for (i = 0, mask = MARKER_MASK; i < size; i++, mask <<= BITS_PER_MARKER)
{
uint64_t masked1, masked2;
masked1 = n1->n & mask;
masked2 = n2->n & mask;
bswap: Improve perform_symbolic_merge [PR103376] Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. This patch just punts on plus if both corresponding bytes are non-zero, otherwise implements the above. 2021-11-25 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): For BIT_IOR_EXPR, if masked1 && masked2 && masked1 != masked2, don't punt, but set the corresponding result byte to MARKER_BYTE_UNKNOWN. For BIT_XOR_EXPR similarly and if masked1 == masked2 and the byte isn't MARKER_BYTE_UNKNOWN, set the corresponding result byte to 0. * gcc.dg/optimize-bswapsi-7.c: New test.
2021-11-25 10:38:33 +01:00
/* If at least one byte is 0, all of 0 | x == 0 ^ x == 0 + x == x. */
if (masked1 && masked2)
{
/* + can carry into upper bits, just punt. */
if (code == PLUS_EXPR)
return NULL;
/* x | x is still x. */
if (code == BIT_IOR_EXPR && masked1 == masked2)
continue;
if (code == BIT_XOR_EXPR)
{
/* x ^ x is 0, but MARKER_BYTE_UNKNOWN stands for
unknown values and unknown ^ unknown is unknown. */
if (masked1 == masked2
&& masked1 != ((uint64_t) MARKER_BYTE_UNKNOWN
<< i * BITS_PER_MARKER))
{
res_n &= ~mask;
continue;
}
}
/* Otherwise set the byte to unknown, it might still be
later masked off. */
res_n |= mask;
}
}
bswap: Improve perform_symbolic_merge [PR103376] Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. This patch just punts on plus if both corresponding bytes are non-zero, otherwise implements the above. 2021-11-25 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): For BIT_IOR_EXPR, if masked1 && masked2 && masked1 != masked2, don't punt, but set the corresponding result byte to MARKER_BYTE_UNKNOWN. For BIT_XOR_EXPR similarly and if masked1 == masked2 and the byte isn't MARKER_BYTE_UNKNOWN, set the corresponding result byte to 0. * gcc.dg/optimize-bswapsi-7.c: New test.
2021-11-25 10:38:33 +01:00
n->n = res_n;
n->n_ops = n1->n_ops + n2->n_ops;
return source_stmt;
}
/* find_bswap_or_nop_1 invokes itself recursively with N and tries to perform
the operation given by the rhs of STMT on the result. If the operation
could successfully be executed the function returns a gimple stmt whose
rhs's first tree is the expression of the source operand and NULL
otherwise. */
gimple *
find_bswap_or_nop_1 (gimple *stmt, struct symbolic_number *n, int limit)
{
enum tree_code code;
tree rhs1, rhs2 = NULL;
gimple *rhs1_stmt, *rhs2_stmt, *source_stmt1;
enum gimple_rhs_class rhs_class;
if (!limit || !is_gimple_assign (stmt))
return NULL;
rhs1 = gimple_assign_rhs1 (stmt);
if (find_bswap_or_nop_load (stmt, rhs1, n))
return stmt;
/* Handle BIT_FIELD_REF. */
if (TREE_CODE (rhs1) == BIT_FIELD_REF
&& TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
{
if (!tree_fits_uhwi_p (TREE_OPERAND (rhs1, 1))
|| !tree_fits_uhwi_p (TREE_OPERAND (rhs1, 2)))
return NULL;
unsigned HOST_WIDE_INT bitsize = tree_to_uhwi (TREE_OPERAND (rhs1, 1));
unsigned HOST_WIDE_INT bitpos = tree_to_uhwi (TREE_OPERAND (rhs1, 2));
if (bitpos % BITS_PER_UNIT == 0
&& bitsize % BITS_PER_UNIT == 0
&& init_symbolic_number (n, TREE_OPERAND (rhs1, 0)))
{
/* Handle big-endian bit numbering in BIT_FIELD_REF. */
if (BYTES_BIG_ENDIAN)
bitpos = TYPE_PRECISION (n->type) - bitpos - bitsize;
/* Shift. */
if (!do_shift_rotate (RSHIFT_EXPR, n, bitpos))
return NULL;
/* Mask. */
uint64_t mask = 0;
uint64_t tmp = (1 << BITS_PER_UNIT) - 1;
for (unsigned i = 0; i < bitsize / BITS_PER_UNIT;
i++, tmp <<= BITS_PER_UNIT)
mask |= (uint64_t) MARKER_MASK << (i * BITS_PER_MARKER);
n->n &= mask;
/* Convert. */
n->type = TREE_TYPE (rhs1);
if (!n->base_addr)
n->range = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
return verify_symbolic_number_p (n, stmt) ? stmt : NULL;
}
return NULL;
}
if (TREE_CODE (rhs1) != SSA_NAME)
return NULL;
code = gimple_assign_rhs_code (stmt);
rhs_class = gimple_assign_rhs_class (stmt);
rhs1_stmt = SSA_NAME_DEF_STMT (rhs1);
if (rhs_class == GIMPLE_BINARY_RHS)
rhs2 = gimple_assign_rhs2 (stmt);
/* Handle unary rhs and binary rhs with integer constants as second
operand. */
if (rhs_class == GIMPLE_UNARY_RHS
|| (rhs_class == GIMPLE_BINARY_RHS
&& TREE_CODE (rhs2) == INTEGER_CST))
{
if (code != BIT_AND_EXPR
&& code != LSHIFT_EXPR
&& code != RSHIFT_EXPR
&& code != LROTATE_EXPR
&& code != RROTATE_EXPR
&& !CONVERT_EXPR_CODE_P (code))
return NULL;
source_stmt1 = find_bswap_or_nop_1 (rhs1_stmt, n, limit - 1);
/* If find_bswap_or_nop_1 returned NULL, STMT is a leaf node and
we have to initialize the symbolic number. */
if (!source_stmt1)
{
if (gimple_assign_load_p (stmt)
|| !init_symbolic_number (n, rhs1))
return NULL;
source_stmt1 = stmt;
}
switch (code)
{
case BIT_AND_EXPR:
{
int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
uint64_t val = int_cst_value (rhs2), mask = 0;
uint64_t tmp = (1 << BITS_PER_UNIT) - 1;
/* Only constants masking full bytes are allowed. */
for (i = 0; i < size; i++, tmp <<= BITS_PER_UNIT)
if ((val & tmp) != 0 && (val & tmp) != tmp)
return NULL;
else if (val & tmp)
mask |= (uint64_t) MARKER_MASK << (i * BITS_PER_MARKER);
n->n &= mask;
}
break;
case LSHIFT_EXPR:
case RSHIFT_EXPR:
case LROTATE_EXPR:
case RROTATE_EXPR:
if (!do_shift_rotate (code, n, (int) TREE_INT_CST_LOW (rhs2)))
return NULL;
break;
CASE_CONVERT:
{
int i, type_size, old_type_size;
tree type;
type = TREE_TYPE (gimple_assign_lhs (stmt));
type_size = TYPE_PRECISION (type);
if (type_size % BITS_PER_UNIT != 0)
return NULL;
type_size /= BITS_PER_UNIT;
if (type_size > 64 / BITS_PER_MARKER)
return NULL;
/* Sign extension: result is dependent on the value. */
old_type_size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
&& HEAD_MARKER (n->n, old_type_size))
for (i = 0; i < type_size - old_type_size; i++)
n->n |= (uint64_t) MARKER_BYTE_UNKNOWN
<< ((type_size - 1 - i) * BITS_PER_MARKER);
if (type_size < 64 / BITS_PER_MARKER)
{
/* If STMT casts to a smaller type mask out the bits not
belonging to the target type. */
n->n &= ((uint64_t) 1 << (type_size * BITS_PER_MARKER)) - 1;
}
n->type = type;
if (!n->base_addr)
n->range = type_size;
}
break;
default:
return NULL;
};
return verify_symbolic_number_p (n, stmt) ? source_stmt1 : NULL;
}
/* Handle binary rhs. */
if (rhs_class == GIMPLE_BINARY_RHS)
{
struct symbolic_number n1, n2;
gimple *source_stmt, *source_stmt2;
if (!rhs2 || TREE_CODE (rhs2) != SSA_NAME)
return NULL;
rhs2_stmt = SSA_NAME_DEF_STMT (rhs2);
switch (code)
{
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case PLUS_EXPR:
source_stmt1 = find_bswap_or_nop_1 (rhs1_stmt, &n1, limit - 1);
if (!source_stmt1)
return NULL;
source_stmt2 = find_bswap_or_nop_1 (rhs2_stmt, &n2, limit - 1);
if (!source_stmt2)
return NULL;
if (TYPE_PRECISION (n1.type) != TYPE_PRECISION (n2.type))
return NULL;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (n1.vuse != n2.vuse)
return NULL;
source_stmt
bswap: Fix up symbolic merging for xor and plus [PR103376] On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote: > This patch implements PR tree-optimization/103345 to merge adjacent > loads when combined with addition or bitwise xor. The current code > in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior, > so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in > the same way at BIT_IOR_EXPR. Unfortunately they aren't exactly the same. They work the same if always at least one operand (or corresponding byte in it) is known to be 0, 0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x, so perform_symbolic_merge has been accepting either that at least one of the bytes is 0 or that both are the same, but that is wrong for ^ and +. The following patch fixes that by passing through the code of binary operation and allowing non-zero masked1 == masked2 through only for BIT_IOR_EXPR. Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. 2021-11-24 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1 or masked2 is 0. (find_bswap_or_nop_1, find_bswap_or_nop, imm_store_chain_info::try_coalesce_bswap): Adjust perform_symbolic_merge callers. * gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
= perform_symbolic_merge (source_stmt1, &n1, source_stmt2, &n2, n,
code);
if (!source_stmt)
return NULL;
if (!verify_symbolic_number_p (n, stmt))
return NULL;
break;
default:
return NULL;
}
return source_stmt;
}
return NULL;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Helper for find_bswap_or_nop and try_coalesce_bswap to compute
*CMPXCHG, *CMPNOP and adjust *N. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
void
find_bswap_or_nop_finalize (struct symbolic_number *n, uint64_t *cmpxchg,
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
uint64_t *cmpnop, bool *cast64_to_32)
{
unsigned rsize;
uint64_t tmpn, mask;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* The number which the find_bswap_or_nop_1 result should match in order
to have a full byte swap. The number is shifted to the right
according to the size of the symbolic number before using it. */
*cmpxchg = CMPXCHG;
*cmpnop = CMPNOP;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
*cast64_to_32 = false;
/* Find real size of result (highest non-zero byte). */
if (n->base_addr)
for (tmpn = n->n, rsize = 0; tmpn; tmpn >>= BITS_PER_MARKER, rsize++);
else
rsize = n->range;
/* Zero out the bits corresponding to untouched bytes in original gimple
expression. */
if (n->range < (int) sizeof (int64_t))
{
mask = ((uint64_t) 1 << (n->range * BITS_PER_MARKER)) - 1;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
if (n->base_addr == NULL
&& n->range == 4
&& int_size_in_bytes (TREE_TYPE (n->src)) == 8)
{
/* If all bytes in n->n are either 0 or in [5..8] range, this
might be a candidate for (unsigned) __builtin_bswap64 (src).
It is not worth it for (unsigned short) __builtin_bswap64 (src)
or (unsigned short) __builtin_bswap32 (src). */
*cast64_to_32 = true;
for (tmpn = n->n; tmpn; tmpn >>= BITS_PER_MARKER)
if ((tmpn & MARKER_MASK)
&& ((tmpn & MARKER_MASK) <= 4 || (tmpn & MARKER_MASK) > 8))
{
*cast64_to_32 = false;
break;
}
}
if (*cast64_to_32)
*cmpxchg &= mask;
else
*cmpxchg >>= (64 / BITS_PER_MARKER - n->range) * BITS_PER_MARKER;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
*cmpnop &= mask;
}
/* Zero out the bits corresponding to unused bytes in the result of the
gimple expression. */
if (rsize < n->range)
{
if (BYTES_BIG_ENDIAN)
{
mask = ((uint64_t) 1 << (rsize * BITS_PER_MARKER)) - 1;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
*cmpxchg &= mask;
if (n->range - rsize == sizeof (int64_t))
*cmpnop = 0;
else
*cmpnop >>= (n->range - rsize) * BITS_PER_MARKER;
}
else
{
mask = ((uint64_t) 1 << (rsize * BITS_PER_MARKER)) - 1;
if (n->range - rsize == sizeof (int64_t))
*cmpxchg = 0;
else
*cmpxchg >>= (n->range - rsize) * BITS_PER_MARKER;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
*cmpnop &= mask;
}
n->range = rsize;
}
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
if (*cast64_to_32)
n->range = 8;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
n->range *= BITS_PER_UNIT;
}
/* Check if STMT completes a bswap implementation or a read in a given
endianness consisting of ORs, SHIFTs and ANDs and sets *BSWAP
accordingly. It also sets N to represent the kind of operations
performed: size of the resulting expression and whether it works on
a memory source, and if so alias-set and vuse. At last, the
function returns a stmt whose rhs's first tree is the source
expression. */
gimple *
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
find_bswap_or_nop (gimple *stmt, struct symbolic_number *n, bool *bswap,
bool *cast64_to_32, uint64_t *mask)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (gimple_get_lhs (stmt)));
if (!tree_fits_uhwi_p (type_size))
return NULL;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* The last parameter determines the depth search limit. It usually
correlates directly to the number n of bytes to be touched. We
increase that number by 2 * (log2(n) + 1) here in order to also
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
cover signed -> unsigned conversions of the src operand as can be seen
in libgcc, and for initial shift/and operation of the src operand. */
int limit = tree_to_uhwi (type_size);
limit += 2 * (1 + (int) ceil_log2 ((unsigned HOST_WIDE_INT) limit));
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple *ins_stmt = find_bswap_or_nop_1 (stmt, n, limit);
if (!ins_stmt)
{
if (gimple_assign_rhs_code (stmt) != CONSTRUCTOR
|| BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
return NULL;
unsigned HOST_WIDE_INT sz = tree_to_uhwi (type_size) * BITS_PER_UNIT;
if (sz != 16 && sz != 32 && sz != 64)
return NULL;
tree rhs = gimple_assign_rhs1 (stmt);
if (CONSTRUCTOR_NELTS (rhs) == 0)
return NULL;
tree eltype = TREE_TYPE (TREE_TYPE (rhs));
unsigned HOST_WIDE_INT eltsz
= int_size_in_bytes (eltype) * BITS_PER_UNIT;
if (TYPE_PRECISION (eltype) != eltsz)
return NULL;
constructor_elt *elt;
unsigned int i;
tree type = build_nonstandard_integer_type (sz, 1);
FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (rhs), i, elt)
{
if (TREE_CODE (elt->value) != SSA_NAME
|| !INTEGRAL_TYPE_P (TREE_TYPE (elt->value)))
return NULL;
struct symbolic_number n1;
gimple *source_stmt
= find_bswap_or_nop_1 (SSA_NAME_DEF_STMT (elt->value), &n1,
limit - 1);
if (!source_stmt)
return NULL;
n1.type = type;
if (!n1.base_addr)
n1.range = sz / BITS_PER_UNIT;
if (i == 0)
{
ins_stmt = source_stmt;
*n = n1;
}
else
{
if (n->vuse != n1.vuse)
return NULL;
struct symbolic_number n0 = *n;
if (!BYTES_BIG_ENDIAN)
{
if (!do_shift_rotate (LSHIFT_EXPR, &n1, i * eltsz))
return NULL;
}
else if (!do_shift_rotate (LSHIFT_EXPR, &n0, eltsz))
return NULL;
ins_stmt
bswap: Fix up symbolic merging for xor and plus [PR103376] On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote: > This patch implements PR tree-optimization/103345 to merge adjacent > loads when combined with addition or bitwise xor. The current code > in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior, > so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in > the same way at BIT_IOR_EXPR. Unfortunately they aren't exactly the same. They work the same if always at least one operand (or corresponding byte in it) is known to be 0, 0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x, so perform_symbolic_merge has been accepting either that at least one of the bytes is 0 or that both are the same, but that is wrong for ^ and +. The following patch fixes that by passing through the code of binary operation and allowing non-zero masked1 == masked2 through only for BIT_IOR_EXPR. Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. 2021-11-24 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1 or masked2 is 0. (find_bswap_or_nop_1, find_bswap_or_nop, imm_store_chain_info::try_coalesce_bswap): Adjust perform_symbolic_merge callers. * gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
= perform_symbolic_merge (ins_stmt, &n0, source_stmt, &n1, n,
BIT_IOR_EXPR);
if (!ins_stmt)
return NULL;
}
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
uint64_t cmpxchg, cmpnop;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
find_bswap_or_nop_finalize (n, &cmpxchg, &cmpnop, cast64_to_32);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* A complete byte swap should make the symbolic number to start with
the largest digit in the highest order byte. Unchanged symbolic
number indicates a read with same endianness as target architecture. */
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
*mask = ~(uint64_t) 0;
if (n->n == cmpnop)
*bswap = false;
else if (n->n == cmpxchg)
*bswap = true;
else
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
{
int set = 0;
for (uint64_t msk = MARKER_MASK; msk; msk <<= BITS_PER_MARKER)
if ((n->n & msk) == 0)
*mask &= ~msk;
else if ((n->n & msk) == (cmpxchg & msk))
set++;
else
return NULL;
if (set < 2)
return NULL;
*bswap = true;
}
/* Useless bit manipulation performed by code. */
if (!n->base_addr && n->n == cmpnop && n->n_ops == 1)
return NULL;
return ins_stmt;
}
const pass_data pass_data_optimize_bswap =
{
GIMPLE_PASS, /* type */
"bswap", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_NONE, /* tv_id */
PROP_ssa, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0, /* todo_flags_finish */
};
class pass_optimize_bswap : public gimple_opt_pass
{
public:
pass_optimize_bswap (gcc::context *ctxt)
: gimple_opt_pass (pass_data_optimize_bswap, ctxt)
{}
/* opt_pass methods: */
virtual bool gate (function *)
{
return flag_expensive_optimizations && optimize && BITS_PER_UNIT == 8;
}
virtual unsigned int execute (function *);
}; // class pass_optimize_bswap
/* Helper function for bswap_replace. Build VIEW_CONVERT_EXPR from
VAL to TYPE. If VAL has different type size, emit a NOP_EXPR cast
first. */
static tree
bswap_view_convert (gimple_stmt_iterator *gsi, tree type, tree val,
bool before)
{
gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (val))
|| POINTER_TYPE_P (TREE_TYPE (val)));
if (TYPE_SIZE (type) != TYPE_SIZE (TREE_TYPE (val)))
{
HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_SIZE (type));
if (POINTER_TYPE_P (TREE_TYPE (val)))
{
gimple *g
= gimple_build_assign (make_ssa_name (pointer_sized_int_node),
NOP_EXPR, val);
if (before)
gsi_insert_before (gsi, g, GSI_SAME_STMT);
else
gsi_insert_after (gsi, g, GSI_NEW_STMT);
val = gimple_assign_lhs (g);
}
tree itype = build_nonstandard_integer_type (prec, 1);
gimple *g = gimple_build_assign (make_ssa_name (itype), NOP_EXPR, val);
if (before)
gsi_insert_before (gsi, g, GSI_SAME_STMT);
else
gsi_insert_after (gsi, g, GSI_NEW_STMT);
val = gimple_assign_lhs (g);
}
return build1 (VIEW_CONVERT_EXPR, type, val);
}
/* Perform the bswap optimization: replace the expression computed in the rhs
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
of gsi_stmt (GSI) (or if NULL add instead of replace) by an equivalent
bswap, load or load + bswap expression.
Which of these alternatives replace the rhs is given by N->base_addr (non
null if a load is needed) and BSWAP. The type, VUSE and set-alias of the
load to perform are also given in N while the builtin bswap invoke is given
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
in FNDEL. Finally, if a load is involved, INS_STMT refers to one of the
load statements involved to construct the rhs in gsi_stmt (GSI) and
N->range gives the size of the rhs expression for maintaining some
statistics.
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
Note that if the replacement involve a load and if gsi_stmt (GSI) is
non-NULL, that stmt is moved just after INS_STMT to do the load with the
same VUSE which can lead to gsi_stmt (GSI) changing of basic block. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
tree
bswap_replace (gimple_stmt_iterator gsi, gimple *ins_stmt, tree fndecl,
tree bswap_type, tree load_type, struct symbolic_number *n,
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bool bswap, uint64_t mask)
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
tree src, tmp, tgt = NULL_TREE;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
gimple *bswap_stmt, *mask_stmt = NULL;
tree_code conv_code = NOP_EXPR;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple *cur_stmt = gsi_stmt (gsi);
src = n->src;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
{
tgt = gimple_assign_lhs (cur_stmt);
if (gimple_assign_rhs_code (cur_stmt) == CONSTRUCTOR
&& tgt
&& VECTOR_TYPE_P (TREE_TYPE (tgt)))
conv_code = VIEW_CONVERT_EXPR;
}
/* Need to load the value from memory first. */
if (n->base_addr)
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple_stmt_iterator gsi_ins = gsi;
if (ins_stmt)
gsi_ins = gsi_for_stmt (ins_stmt);
tree addr_expr, addr_tmp, val_expr, val_tmp;
tree load_offset_ptr, aligned_load_type;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple *load_stmt;
unsigned align = get_object_alignment (src);
poly_int64 load_offset = 0;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
{
basic_block ins_bb = gimple_bb (ins_stmt);
basic_block cur_bb = gimple_bb (cur_stmt);
if (!dominated_by_p (CDI_DOMINATORS, cur_bb, ins_bb))
return NULL_TREE;
/* Move cur_stmt just before one of the load of the original
to ensure it has the same VUSE. See PR61517 for what could
go wrong. */
if (gimple_bb (cur_stmt) != gimple_bb (ins_stmt))
reset_flow_sensitive_info (gimple_assign_lhs (cur_stmt));
gsi_move_before (&gsi, &gsi_ins);
gsi = gsi_for_stmt (cur_stmt);
}
else
gsi = gsi_ins;
/* Compute address to load from and cast according to the size
of the load. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
addr_expr = build_fold_addr_expr (src);
if (is_gimple_mem_ref_addr (addr_expr))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
addr_tmp = unshare_expr (addr_expr);
else
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
addr_tmp = unshare_expr (n->base_addr);
if (!is_gimple_mem_ref_addr (addr_tmp))
addr_tmp = force_gimple_operand_gsi_1 (&gsi, addr_tmp,
is_gimple_mem_ref_addr,
NULL_TREE, true,
GSI_SAME_STMT);
load_offset = n->bytepos;
if (n->offset)
{
tree off
= force_gimple_operand_gsi (&gsi, unshare_expr (n->offset),
true, NULL_TREE, true,
GSI_SAME_STMT);
gimple *stmt
= gimple_build_assign (make_ssa_name (TREE_TYPE (addr_tmp)),
POINTER_PLUS_EXPR, addr_tmp, off);
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
addr_tmp = gimple_assign_lhs (stmt);
}
}
/* Perform the load. */
aligned_load_type = load_type;
if (align < TYPE_ALIGN (load_type))
aligned_load_type = build_aligned_type (load_type, align);
load_offset_ptr = build_int_cst (n->alias_set, load_offset);
val_expr = fold_build2 (MEM_REF, aligned_load_type, addr_tmp,
load_offset_ptr);
if (!bswap)
{
if (n->range == 16)
nop_stats.found_16bit++;
else if (n->range == 32)
nop_stats.found_32bit++;
else
{
gcc_assert (n->range == 64);
nop_stats.found_64bit++;
}
/* Convert the result of load if necessary. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (tgt && !useless_type_conversion_p (TREE_TYPE (tgt), load_type))
{
val_tmp = make_temp_ssa_name (aligned_load_type, NULL,
"load_dst");
load_stmt = gimple_build_assign (val_tmp, val_expr);
gimple_set_vuse (load_stmt, n->vuse);
gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT);
if (conv_code == VIEW_CONVERT_EXPR)
val_tmp = bswap_view_convert (&gsi, TREE_TYPE (tgt), val_tmp,
true);
gimple_assign_set_rhs_with_ops (&gsi, conv_code, val_tmp);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
update_stmt (cur_stmt);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else if (cur_stmt)
{
gimple_assign_set_rhs_with_ops (&gsi, MEM_REF, val_expr);
gimple_set_vuse (cur_stmt, n->vuse);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
update_stmt (cur_stmt);
}
else
{
tgt = make_ssa_name (load_type);
cur_stmt = gimple_build_assign (tgt, MEM_REF, val_expr);
gimple_set_vuse (cur_stmt, n->vuse);
gsi_insert_before (&gsi, cur_stmt, GSI_SAME_STMT);
}
if (dump_file)
{
fprintf (dump_file,
"%d bit load in target endianness found at: ",
(int) n->range);
print_gimple_stmt (dump_file, cur_stmt, 0);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
return tgt;
}
else
{
val_tmp = make_temp_ssa_name (aligned_load_type, NULL, "load_dst");
load_stmt = gimple_build_assign (val_tmp, val_expr);
gimple_set_vuse (load_stmt, n->vuse);
gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT);
}
src = val_tmp;
}
else if (!bswap)
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple *g = NULL;
if (tgt && !useless_type_conversion_p (TREE_TYPE (tgt), TREE_TYPE (src)))
{
if (!is_gimple_val (src))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
return NULL_TREE;
if (conv_code == VIEW_CONVERT_EXPR)
src = bswap_view_convert (&gsi, TREE_TYPE (tgt), src, true);
g = gimple_build_assign (tgt, conv_code, src);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else if (cur_stmt)
g = gimple_build_assign (tgt, src);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else
tgt = src;
if (n->range == 16)
nop_stats.found_16bit++;
else if (n->range == 32)
nop_stats.found_32bit++;
else
{
gcc_assert (n->range == 64);
nop_stats.found_64bit++;
}
if (dump_file)
{
fprintf (dump_file,
"%d bit reshuffle in target endianness found at: ",
(int) n->range);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
print_gimple_stmt (dump_file, cur_stmt, 0);
else
{
Convert dump and optgroup flags to enums gcc/brig/ChangeLog: * brigfrontend/brig-to-generic.cc (brig_to_generic::write_globals): Use TDF_NONE rather than 0. (dump_function): Likewise. gcc/c-family/ChangeLog: * c-pretty-print.c (c_pretty_printer::statement): Use TDF_NONE rather than 0. gcc/ChangeLog: * cfg.c (debug): Use TDF_NONE rather than 0. * cfghooks.c (debug): Likewise. * dumpfile.c (DUMP_FILE_INFO): Likewise; also for OPTGROUP. (struct dump_option_value_info): Convert to... (struct kv_pair): ...this template type. (dump_options): Convert to kv_pair<dump_flags_t>; use TDF_NONE rather than 0. (optinfo_verbosity_options): Likewise. (optgroup_options): Convert to kv_pair<optgroup_flags_t>; use OPTGROUP_NONE. (gcc::dump_manager::dump_register): Use optgroup_flags_t rather than int for "optgroup_flags" param. (dump_generic_expr_loc): Use dump_flags_t rather than int for "dump_kind" param. (dump_dec): Likewise. (dump_finish): Use TDF_NONE rather than 0. (gcc::dump_manager::opt_info_enable_passes): Use optgroup_flags_t rather than int for "optgroup_flags" param. Use TDF_NONE rather than 0. Update for change to option_ptr. (opt_info_switch_p_1): Convert "optgroup_flags" param from int * to optgroup_flags_t *. Use TDF_NONE and OPTGROUP_NONE rather than 0. Update for changes to optinfo_verbosity_options and optgroup_options. (opt_info_switch_p): Convert optgroup_flags from int to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for "dump_kind" param. * dumpfile.h (TDF_ADDRESS, TDF_SLIM, TDF_RAW, TDF_DETAILS, TDF_STATS, TDF_BLOCKS, TDF_VOPS, TDF_LINENO, TDF_UID) TDF_STMTADDR, TDF_GRAPH, TDF_MEMSYMS, TDF_RHS_ONLY, TDF_ASMNAME, TDF_EH, TDF_NOUID, TDF_ALIAS, TDF_ENUMERATE_LOCALS, TDF_CSELIB, TDF_SCEV, TDF_GIMPLE, TDF_FOLDING, MSG_OPTIMIZED_LOCATIONS, MSG_MISSED_OPTIMIZATION, MSG_NOTE, MSG_ALL, TDF_COMPARE_DEBUG, TDF_NONE): Convert from macros to... (enum dump_flag): ...this new enum. (dump_flags_t): Update to use enum. (operator|, operator&, operator~, operator|=, operator&=): Implement for dump_flags_t. (OPTGROUP_NONE, OPTGROUP_IPA, OPTGROUP_LOOP, OPTGROUP_INLINE, OPTGROUP_OMP, OPTGROUP_VEC, OPTGROUP_OTHER, OPTGROUP_ALL): Convert from macros to... (enum optgroup_flag): ...this new enum. (optgroup_flags_t): New typedef. (operator|, operator|=): Implement for optgroup_flags_t. (struct dump_file_info): Convert field "alt_flags" to dump_flags_t. Convert field "optgroup_flags" to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for param. (dump_generic_expr_loc): Likewise. (dump_dec): Likewise. (dump_register): Convert param "optgroup_flags" to optgroup_flags_t. (opt_info_enable_passes): Likewise. * early-remat.c (early_remat::dump_edge_list): Use TDF_NONE rather than 0. * gimple-pretty-print.c (debug): Likewise. * gimple-ssa-store-merging.c (bswap_replace): Likewise. (merged_store_group::apply_stores): Likewise. * gimple-ssa-strength-reduction.c (insert_initializers): Likewise. * gimple.c (verify_gimple_pp): Likewise. * graphite-poly.c (print_pbb_body): Likewise. * passes.c (pass_manager::register_one_dump_file): Convert local "optgroup_flags" to optgroup_flags_t. * print-tree.c (print_node): Use TDF_NONE rather than 0. (debug): Likewise. (debug_body): Likewise. * tree-pass.h (struct pass_data): Convert field "optgroup_flags" to optgroup_flags_t. * tree-pretty-print.c (print_struct_decl): Use TDF_NONE rather than 0. * tree-ssa-math-opts.c (convert_mult_to_fma_1): Likewise. (convert_mult_to_fma): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-ssa-sccvn.c (vn_eliminate): Likewise. * tree-vect-data-refs.c (dump_lower_bound): Convert param "dump_kind" to dump_flags_t. From-SVN: r261325
2018-06-08 14:50:19 +02:00
print_generic_expr (dump_file, tgt, TDF_NONE);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
fprintf (dump_file, "\n");
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
gsi_replace (&gsi, g, true);
return tgt;
}
else if (TREE_CODE (src) == BIT_FIELD_REF)
src = TREE_OPERAND (src, 0);
if (n->range == 16)
bswap_stats.found_16bit++;
else if (n->range == 32)
bswap_stats.found_32bit++;
else
{
gcc_assert (n->range == 64);
bswap_stats.found_64bit++;
}
tmp = src;
/* Convert the src expression if necessary. */
if (!useless_type_conversion_p (TREE_TYPE (tmp), bswap_type))
{
gimple *convert_stmt;
tmp = make_temp_ssa_name (bswap_type, NULL, "bswapsrc");
convert_stmt = gimple_build_assign (tmp, NOP_EXPR, src);
gsi_insert_before (&gsi, convert_stmt, GSI_SAME_STMT);
}
/* Canonical form for 16 bit bswap is a rotate expression. Only 16bit values
are considered as rotation of 2N bit values by N bits is generally not
equivalent to a bswap. Consider for instance 0x01020304 r>> 16 which
gives 0x03040102 while a bswap for that value is 0x04030201. */
if (bswap && n->range == 16)
{
tree count = build_int_cst (NULL, BITS_PER_UNIT);
src = fold_build2 (LROTATE_EXPR, bswap_type, tmp, count);
bswap_stmt = gimple_build_assign (NULL, src);
}
else
bswap_stmt = gimple_build_call (fndecl, 1, tmp);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (tgt == NULL_TREE)
tgt = make_ssa_name (bswap_type);
tmp = tgt;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
if (mask != ~(uint64_t) 0)
{
tree m = build_int_cst (bswap_type, mask);
tmp = make_temp_ssa_name (bswap_type, NULL, "bswapdst");
gimple_set_lhs (bswap_stmt, tmp);
mask_stmt = gimple_build_assign (tgt, BIT_AND_EXPR, tmp, m);
tmp = tgt;
}
/* Convert the result if necessary. */
if (!useless_type_conversion_p (TREE_TYPE (tgt), bswap_type))
{
tmp = make_temp_ssa_name (bswap_type, NULL, "bswapdst");
tree atmp = tmp;
gimple_stmt_iterator gsi2 = gsi;
if (conv_code == VIEW_CONVERT_EXPR)
atmp = bswap_view_convert (&gsi2, TREE_TYPE (tgt), tmp, false);
gimple *convert_stmt = gimple_build_assign (tgt, conv_code, atmp);
gsi_insert_after (&gsi2, convert_stmt, GSI_SAME_STMT);
}
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
gimple_set_lhs (mask_stmt ? mask_stmt : bswap_stmt, tmp);
if (dump_file)
{
fprintf (dump_file, "%d bit bswap implementation found at: ",
(int) n->range);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
print_gimple_stmt (dump_file, cur_stmt, 0);
else
{
Convert dump and optgroup flags to enums gcc/brig/ChangeLog: * brigfrontend/brig-to-generic.cc (brig_to_generic::write_globals): Use TDF_NONE rather than 0. (dump_function): Likewise. gcc/c-family/ChangeLog: * c-pretty-print.c (c_pretty_printer::statement): Use TDF_NONE rather than 0. gcc/ChangeLog: * cfg.c (debug): Use TDF_NONE rather than 0. * cfghooks.c (debug): Likewise. * dumpfile.c (DUMP_FILE_INFO): Likewise; also for OPTGROUP. (struct dump_option_value_info): Convert to... (struct kv_pair): ...this template type. (dump_options): Convert to kv_pair<dump_flags_t>; use TDF_NONE rather than 0. (optinfo_verbosity_options): Likewise. (optgroup_options): Convert to kv_pair<optgroup_flags_t>; use OPTGROUP_NONE. (gcc::dump_manager::dump_register): Use optgroup_flags_t rather than int for "optgroup_flags" param. (dump_generic_expr_loc): Use dump_flags_t rather than int for "dump_kind" param. (dump_dec): Likewise. (dump_finish): Use TDF_NONE rather than 0. (gcc::dump_manager::opt_info_enable_passes): Use optgroup_flags_t rather than int for "optgroup_flags" param. Use TDF_NONE rather than 0. Update for change to option_ptr. (opt_info_switch_p_1): Convert "optgroup_flags" param from int * to optgroup_flags_t *. Use TDF_NONE and OPTGROUP_NONE rather than 0. Update for changes to optinfo_verbosity_options and optgroup_options. (opt_info_switch_p): Convert optgroup_flags from int to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for "dump_kind" param. * dumpfile.h (TDF_ADDRESS, TDF_SLIM, TDF_RAW, TDF_DETAILS, TDF_STATS, TDF_BLOCKS, TDF_VOPS, TDF_LINENO, TDF_UID) TDF_STMTADDR, TDF_GRAPH, TDF_MEMSYMS, TDF_RHS_ONLY, TDF_ASMNAME, TDF_EH, TDF_NOUID, TDF_ALIAS, TDF_ENUMERATE_LOCALS, TDF_CSELIB, TDF_SCEV, TDF_GIMPLE, TDF_FOLDING, MSG_OPTIMIZED_LOCATIONS, MSG_MISSED_OPTIMIZATION, MSG_NOTE, MSG_ALL, TDF_COMPARE_DEBUG, TDF_NONE): Convert from macros to... (enum dump_flag): ...this new enum. (dump_flags_t): Update to use enum. (operator|, operator&, operator~, operator|=, operator&=): Implement for dump_flags_t. (OPTGROUP_NONE, OPTGROUP_IPA, OPTGROUP_LOOP, OPTGROUP_INLINE, OPTGROUP_OMP, OPTGROUP_VEC, OPTGROUP_OTHER, OPTGROUP_ALL): Convert from macros to... (enum optgroup_flag): ...this new enum. (optgroup_flags_t): New typedef. (operator|, operator|=): Implement for optgroup_flags_t. (struct dump_file_info): Convert field "alt_flags" to dump_flags_t. Convert field "optgroup_flags" to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for param. (dump_generic_expr_loc): Likewise. (dump_dec): Likewise. (dump_register): Convert param "optgroup_flags" to optgroup_flags_t. (opt_info_enable_passes): Likewise. * early-remat.c (early_remat::dump_edge_list): Use TDF_NONE rather than 0. * gimple-pretty-print.c (debug): Likewise. * gimple-ssa-store-merging.c (bswap_replace): Likewise. (merged_store_group::apply_stores): Likewise. * gimple-ssa-strength-reduction.c (insert_initializers): Likewise. * gimple.c (verify_gimple_pp): Likewise. * graphite-poly.c (print_pbb_body): Likewise. * passes.c (pass_manager::register_one_dump_file): Convert local "optgroup_flags" to optgroup_flags_t. * print-tree.c (print_node): Use TDF_NONE rather than 0. (debug): Likewise. (debug_body): Likewise. * tree-pass.h (struct pass_data): Convert field "optgroup_flags" to optgroup_flags_t. * tree-pretty-print.c (print_struct_decl): Use TDF_NONE rather than 0. * tree-ssa-math-opts.c (convert_mult_to_fma_1): Likewise. (convert_mult_to_fma): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-ssa-sccvn.c (vn_eliminate): Likewise. * tree-vect-data-refs.c (dump_lower_bound): Convert param "dump_kind" to dump_flags_t. From-SVN: r261325
2018-06-08 14:50:19 +02:00
print_generic_expr (dump_file, tgt, TDF_NONE);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
fprintf (dump_file, "\n");
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (cur_stmt)
{
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
if (mask_stmt)
gsi_insert_after (&gsi, mask_stmt, GSI_SAME_STMT);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gsi_insert_after (&gsi, bswap_stmt, GSI_SAME_STMT);
gsi_remove (&gsi, true);
}
else
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
{
gsi_insert_before (&gsi, bswap_stmt, GSI_SAME_STMT);
if (mask_stmt)
gsi_insert_before (&gsi, mask_stmt, GSI_SAME_STMT);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
return tgt;
}
/* Try to optimize an assignment CUR_STMT with CONSTRUCTOR on the rhs
using bswap optimizations. CDI_DOMINATORS need to be
computed on entry. Return true if it has been optimized and
TODO_update_ssa is needed. */
static bool
maybe_optimize_vector_constructor (gimple *cur_stmt)
{
tree fndecl = NULL_TREE, bswap_type = NULL_TREE, load_type;
struct symbolic_number n;
bool bswap;
gcc_assert (is_gimple_assign (cur_stmt)
&& gimple_assign_rhs_code (cur_stmt) == CONSTRUCTOR);
tree rhs = gimple_assign_rhs1 (cur_stmt);
if (!VECTOR_TYPE_P (TREE_TYPE (rhs))
|| !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (rhs)))
|| gimple_assign_lhs (cur_stmt) == NULL_TREE)
return false;
HOST_WIDE_INT sz = int_size_in_bytes (TREE_TYPE (rhs)) * BITS_PER_UNIT;
switch (sz)
{
case 16:
load_type = bswap_type = uint16_type_node;
break;
case 32:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing)
{
load_type = uint32_type_node;
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
bswap_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
else
return false;
break;
case 64:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
&& (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
|| (word_mode == SImode
&& builtin_decl_explicit_p (BUILT_IN_BSWAP32)
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing)))
{
load_type = uint64_type_node;
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
bswap_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
else
return false;
break;
default:
return false;
}
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bool cast64_to_32;
uint64_t mask;
gimple *ins_stmt = find_bswap_or_nop (cur_stmt, &n, &bswap,
&cast64_to_32, &mask);
if (!ins_stmt
|| n.range != (unsigned HOST_WIDE_INT) sz
|| cast64_to_32
|| mask != ~(uint64_t) 0)
return false;
if (bswap && !fndecl && n.range != 16)
return false;
memset (&nop_stats, 0, sizeof (nop_stats));
memset (&bswap_stats, 0, sizeof (bswap_stats));
return bswap_replace (gsi_for_stmt (cur_stmt), ins_stmt, fndecl,
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bswap_type, load_type, &n, bswap, mask) != NULL_TREE;
}
/* Find manual byte swap implementations as well as load in a given
endianness. Byte swaps are turned into a bswap builtin invokation
while endian loads are converted to bswap builtin invokation or
simple load according to the target endianness. */
unsigned int
pass_optimize_bswap::execute (function *fun)
{
basic_block bb;
bool bswap32_p, bswap64_p;
bool changed = false;
tree bswap32_type = NULL_TREE, bswap64_type = NULL_TREE;
bswap32_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing);
bswap64_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
&& (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
|| (bswap32_p && word_mode == SImode)));
/* Determine the argument type of the builtins. The code later on
assumes that the return and argument type are the same. */
if (bswap32_p)
{
tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
bswap32_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
if (bswap64_p)
{
tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
bswap64_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
memset (&nop_stats, 0, sizeof (nop_stats));
memset (&bswap_stats, 0, sizeof (bswap_stats));
calculate_dominance_info (CDI_DOMINATORS);
FOR_EACH_BB_FN (bb, fun)
{
gimple_stmt_iterator gsi;
/* We do a reverse scan for bswap patterns to make sure we get the
widest match. As bswap pattern matching doesn't handle previously
inserted smaller bswap replacements as sub-patterns, the wider
variant wouldn't be detected. */
for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);)
{
gimple *ins_stmt, *cur_stmt = gsi_stmt (gsi);
tree fndecl = NULL_TREE, bswap_type = NULL_TREE, load_type;
enum tree_code code;
struct symbolic_number n;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bool bswap, cast64_to_32;
uint64_t mask;
/* This gsi_prev (&gsi) is not part of the for loop because cur_stmt
might be moved to a different basic block by bswap_replace and gsi
must not points to it if that's the case. Moving the gsi_prev
there make sure that gsi points to the statement previous to
cur_stmt while still making sure that all statements are
considered in this basic block. */
gsi_prev (&gsi);
if (!is_gimple_assign (cur_stmt))
continue;
code = gimple_assign_rhs_code (cur_stmt);
switch (code)
{
case LROTATE_EXPR:
case RROTATE_EXPR:
if (!tree_fits_uhwi_p (gimple_assign_rhs2 (cur_stmt))
|| tree_to_uhwi (gimple_assign_rhs2 (cur_stmt))
% BITS_PER_UNIT)
continue;
/* Fall through. */
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case PLUS_EXPR:
break;
case CONSTRUCTOR:
{
tree rhs = gimple_assign_rhs1 (cur_stmt);
if (VECTOR_TYPE_P (TREE_TYPE (rhs))
&& INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (rhs))))
break;
}
continue;
default:
continue;
}
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
ins_stmt = find_bswap_or_nop (cur_stmt, &n, &bswap,
&cast64_to_32, &mask);
if (!ins_stmt)
continue;
switch (n.range)
{
case 16:
/* Already in canonical form, nothing to do. */
if (code == LROTATE_EXPR || code == RROTATE_EXPR)
continue;
load_type = bswap_type = uint16_type_node;
break;
case 32:
load_type = uint32_type_node;
if (bswap32_p)
{
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
bswap_type = bswap32_type;
}
break;
case 64:
load_type = uint64_type_node;
if (bswap64_p)
{
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
bswap_type = bswap64_type;
}
break;
default:
continue;
}
if (bswap && !fndecl && n.range != 16)
continue;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (bswap_replace (gsi_for_stmt (cur_stmt), ins_stmt, fndecl,
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bswap_type, load_type, &n, bswap, mask))
changed = true;
}
}
statistics_counter_event (fun, "16-bit nop implementations found",
nop_stats.found_16bit);
statistics_counter_event (fun, "32-bit nop implementations found",
nop_stats.found_32bit);
statistics_counter_event (fun, "64-bit nop implementations found",
nop_stats.found_64bit);
statistics_counter_event (fun, "16-bit bswap implementations found",
bswap_stats.found_16bit);
statistics_counter_event (fun, "32-bit bswap implementations found",
bswap_stats.found_32bit);
statistics_counter_event (fun, "64-bit bswap implementations found",
bswap_stats.found_64bit);
return (changed ? TODO_update_ssa : 0);
}
} // anon namespace
gimple_opt_pass *
make_pass_optimize_bswap (gcc::context *ctxt)
{
return new pass_optimize_bswap (ctxt);
}
namespace {
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Struct recording one operand for the store, which is either a constant,
then VAL represents the constant and all the other fields are zero, or
a memory load, then VAL represents the reference, BASE_ADDR is non-NULL
and the other fields also reflect the memory load, or an SSA name, then
VAL represents the SSA name and all the other fields are zero, */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
class store_operand_info
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
public:
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree val;
tree base_addr;
poly_uint64 bitsize;
poly_uint64 bitpos;
poly_uint64 bitregion_start;
poly_uint64 bitregion_end;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
gimple *stmt;
bool bit_not_p;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_operand_info ();
};
store_operand_info::store_operand_info ()
: val (NULL_TREE), base_addr (NULL_TREE), bitsize (0), bitpos (0),
bitregion_start (0), bitregion_end (0), stmt (NULL), bit_not_p (false)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Struct recording the information about a single store of an immediate
to memory. These are created in the first phase and coalesced into
merged_store_group objects in the second phase. */
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
class store_immediate_info
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
public:
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT bitsize;
unsigned HOST_WIDE_INT bitpos;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT bitregion_start;
/* This is one past the last bit of the bit region. */
unsigned HOST_WIDE_INT bitregion_end;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple *stmt;
unsigned int order;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
/* INTEGER_CST for constant store, STRING_CST for string store,
MEM_REF for memory copy, BIT_*_EXPR for logical bitwise operation,
BIT_INSERT_EXPR for bit insertion.
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
LROTATE_EXPR if it can be only bswap optimized and
ops are not really meaningful.
NOP_EXPR if bswap optimization detected identity, ops
are not meaningful. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
enum tree_code rhs_code;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Two fields for bswap optimization purposes. */
struct symbolic_number n;
gimple *ins_stmt;
/* True if BIT_{AND,IOR,XOR}_EXPR result is inverted before storing. */
bool bit_not_p;
/* True if ops have been swapped and thus ops[1] represents
rhs1 of BIT_{AND,IOR,XOR}_EXPR and ops[0] represents rhs2. */
bool ops_swapped_p;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
/* The index number of the landing pad, or 0 if there is none. */
int lp_nr;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Operands. For BIT_*_EXPR rhs_code both operands are used, otherwise
just the first one. */
store_operand_info ops[2];
store_immediate_info (unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT,
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple *, unsigned int, enum tree_code,
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
struct symbolic_number &, gimple *, bool, int,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
const store_operand_info &,
const store_operand_info &);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
};
store_immediate_info::store_immediate_info (unsigned HOST_WIDE_INT bs,
unsigned HOST_WIDE_INT bp,
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT brs,
unsigned HOST_WIDE_INT bre,
gimple *st,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
unsigned int ord,
enum tree_code rhscode,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
struct symbolic_number &nr,
gimple *ins_stmtp,
bool bitnotp,
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
int nr2,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
const store_operand_info &op0r,
const store_operand_info &op1r)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
: bitsize (bs), bitpos (bp), bitregion_start (brs), bitregion_end (bre),
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
stmt (st), order (ord), rhs_code (rhscode), n (nr),
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
ins_stmt (ins_stmtp), bit_not_p (bitnotp), ops_swapped_p (false),
lp_nr (nr2), ops { op0r, op1r }
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Struct representing a group of stores to contiguous memory locations.
These are produced by the second phase (coalescing) and consumed in the
third phase that outputs the widened stores. */
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
class merged_store_group
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
public:
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT start;
unsigned HOST_WIDE_INT width;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT bitregion_start;
unsigned HOST_WIDE_INT bitregion_end;
/* The size of the allocated memory for val and mask. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT buf_size;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT align_base;
poly_uint64 load_align_base[2];
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned int align;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
unsigned int load_align[2];
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned int first_order;
unsigned int last_order;
bool bit_insertion;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
bool string_concatenation;
bool only_constants;
bool consecutive;
unsigned int first_nonmergeable_order;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
int lp_nr;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
auto_vec<store_immediate_info *> stores;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* We record the first and last original statements in the sequence because
we'll need their vuse/vdef and replacement position. It's easier to keep
track of them separately as 'stores' is reordered by apply_stores. */
gimple *last_stmt;
gimple *first_stmt;
unsigned char *val;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned char *mask;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
merged_store_group (store_immediate_info *);
~merged_store_group ();
bool can_be_merged_into (store_immediate_info *);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
void merge_into (store_immediate_info *);
void merge_overlapping (store_immediate_info *);
bool apply_stores ();
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
private:
void do_merge (store_immediate_info *);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
};
/* Debug helper. Dump LEN elements of byte array PTR to FD in hex. */
static void
dump_char_array (FILE *fd, unsigned char *ptr, unsigned int len)
{
if (!fd)
return;
for (unsigned int i = 0; i < len; i++)
fprintf (fd, "%02x ", ptr[i]);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
fprintf (fd, "\n");
}
/* Clear out LEN bits starting from bit START in the byte array
PTR. This clears the bits to the *right* from START.
START must be within [0, BITS_PER_UNIT) and counts starting from
the least significant bit. */
static void
clear_bit_region_be (unsigned char *ptr, unsigned int start,
unsigned int len)
{
if (len == 0)
return;
/* Clear len bits to the right of start. */
else if (len <= start + 1)
{
unsigned char mask = (~(~0U << len));
mask = mask << (start + 1U - len);
ptr[0] &= ~mask;
}
else if (start != BITS_PER_UNIT - 1)
{
clear_bit_region_be (ptr, start, (start % BITS_PER_UNIT) + 1);
clear_bit_region_be (ptr + 1, BITS_PER_UNIT - 1,
len - (start % BITS_PER_UNIT) - 1);
}
else if (start == BITS_PER_UNIT - 1
&& len > BITS_PER_UNIT)
{
unsigned int nbytes = len / BITS_PER_UNIT;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
memset (ptr, 0, nbytes);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (len % BITS_PER_UNIT != 0)
clear_bit_region_be (ptr + nbytes, BITS_PER_UNIT - 1,
len % BITS_PER_UNIT);
}
else
gcc_unreachable ();
}
/* In the byte array PTR clear the bit region starting at bit
START and is LEN bits wide.
For regions spanning multiple bytes do this recursively until we reach
zero LEN or a region contained within a single byte. */
static void
clear_bit_region (unsigned char *ptr, unsigned int start,
unsigned int len)
{
/* Degenerate base case. */
if (len == 0)
return;
else if (start >= BITS_PER_UNIT)
clear_bit_region (ptr + 1, start - BITS_PER_UNIT, len);
/* Second base case. */
else if ((start + len) <= BITS_PER_UNIT)
{
unsigned char mask = (~0U) << (unsigned char) (BITS_PER_UNIT - len);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
mask >>= BITS_PER_UNIT - (start + len);
ptr[0] &= ~mask;
return;
}
/* Clear most significant bits in a byte and proceed with the next byte. */
else if (start != 0)
{
clear_bit_region (ptr, start, BITS_PER_UNIT - start);
clear_bit_region (ptr + 1, 0, len - (BITS_PER_UNIT - start));
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Whole bytes need to be cleared. */
else if (start == 0 && len > BITS_PER_UNIT)
{
unsigned int nbytes = len / BITS_PER_UNIT;
/* We could recurse on each byte but we clear whole bytes, so a simple
memset will do. */
memset (ptr, '\0', nbytes);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Clear the remaining sub-byte region if there is one. */
if (len % BITS_PER_UNIT != 0)
clear_bit_region (ptr + nbytes, 0, len % BITS_PER_UNIT);
}
else
gcc_unreachable ();
}
/* Write BITLEN bits of EXPR to the byte array PTR at
bit position BITPOS. PTR should contain TOTAL_BYTES elements.
Return true if the operation succeeded. */
static bool
encode_tree_to_bitpos (tree expr, unsigned char *ptr, int bitlen, int bitpos,
unsigned int total_bytes)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
unsigned int first_byte = bitpos / BITS_PER_UNIT;
bool sub_byte_op_p = ((bitlen % BITS_PER_UNIT)
|| (bitpos % BITS_PER_UNIT)
Make more use of int_mode_for_size This patch converts more places that could use int_mode_for_size instead of mode_for_size. This is in preparation for an upcoming patch that makes mode_for_size itself return an opt_mode. require () seems like the right choice in expand_builtin_powi because we have got past the point of backing out. We go on to do: op1 = expand_expr (arg1, NULL_RTX, mode2, EXPAND_NORMAL); if (GET_MODE (op1) != mode2) op1 = convert_to_mode (mode2, op1, 0); which would be invalid for (and have failed for) BLKmode. In get_builtin_sync_mode and expand_ifn_atomic_compare_exchange, the possible bitsizes are {8, 16, 32, 64, 128}, all of which give target-independent integer modes (up to TImode). The comment above the call in get_builtin_sync_mode makes clear that an integer mode must be found. We can use require () in expand_builtin_atomic_clear and expand_builtin_atomic_test_and_set because there's always an integer mode for the boolean type. The same goes for the POINTER_SIZE request in layout_type. Similarly we can use require () in combine_instructions and gen_lowpart_common because there's always an integer mode for HOST_BITS_PER_WIDE_INT (DImode when BITS_PER_UNIT == 8), and HOST_BITS_PER_DOUBLE_INT (TImode). The calls in aarch64_function_value, arm_function_value, aapcs_allocate_return_reg and mips_function_value_1 are handling cases in which a big-endian target passes or returns values at the most significant end of a register. In each case the ABI constrains the size to a small amount and does not handle non-power-of-2 sizes wider than a word. The calls in c6x_expand_movmem, i386.c:emit_memset, lm32_block_move_inline, microblaze_block_move_straight and mips_block_move_straight are dealing with expansions of block memory operations using register-wise operations, and those registers must have non-BLK mode. The reason for using require () in ix86_expand_sse_cmp, mips_expand_ins_as_unaligned_store, spu.c:adjust_operand and spu_emit_branch_and_set is that we go on to emit non-call instructions that use registers of that mode, which wouldn't be valid for BLKmode. 2017-09-05 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * builtins.c (expand_builtin_powi): Use int_mode_for_size. (get_builtin_sync_mode): Likewise. (expand_ifn_atomic_compare_exchange): Likewise. (expand_builtin_atomic_clear): Likewise. (expand_builtin_atomic_test_and_set): Likewise. (fold_builtin_atomic_always_lock_free): Likewise. * calls.c (compute_argument_addresses): Likewise. (emit_library_call_value_1): Likewise. (store_one_arg): Likewise. * combine.c (combine_instructions): Likewise. * config/aarch64/aarch64.c (aarch64_function_value): Likewise. * config/arm/arm.c (arm_function_value): Likewise. (aapcs_allocate_return_reg): Likewise. * config/c6x/c6x.c (c6x_expand_movmem): Likewise. * config/i386/i386.c (construct_container): Likewise. (ix86_gimplify_va_arg): Likewise. (ix86_expand_sse_cmp): Likewise. (emit_memmov): Likewise. (emit_memset): Likewise. (expand_small_movmem_or_setmem): Likewise. (ix86_expand_pextr): Likewise. (ix86_expand_pinsr): Likewise. * config/lm32/lm32.c (lm32_block_move_inline): Likewise. * config/microblaze/microblaze.c (microblaze_block_move_straight): Likewise. * config/mips/mips.c (mips_function_value_1) Likewise. (mips_block_move_straight): Likewise. (mips_expand_ins_as_unaligned_store): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_darwin64_record_arg_advance_flush): Likewise. (rs6000_darwin64_record_arg_flush): Likewise. * config/rs6000/rs6000.c (rs6000_darwin64_record_arg_advance_flush): Likewise. (rs6000_darwin64_record_arg_flush): Likewise. * config/sparc/sparc.c (sparc_function_arg_1): Likewise. (sparc_function_value_1): Likewise. * config/spu/spu.c (adjust_operand): Likewise. (spu_emit_branch_or_set): Likewise. (arith_immediate_p): Likewise. * emit-rtl.c (gen_lowpart_common): Likewise. * expr.c (expand_expr_real_1): Likewise. * function.c (assign_parm_setup_block): Likewise. * gimple-ssa-store-merging.c (encode_tree_to_bitpos): Likewise. * reload1.c (alter_reg): Likewise. * stor-layout.c (mode_for_vector): Likewise. (layout_type): Likewise. gcc/ada/ * gcc-interface/utils2.c (build_load_modify_store): Use int_mode_for_size. From-SVN: r251726
2017-09-05 21:57:01 +02:00
|| !int_mode_for_size (bitlen, 0).exists ());
bool empty_ctor_p
= (TREE_CODE (expr) == CONSTRUCTOR
&& CONSTRUCTOR_NELTS (expr) == 0
&& TYPE_SIZE_UNIT (TREE_TYPE (expr))
&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (expr))));
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (!sub_byte_op_p)
{
if (first_byte >= total_bytes)
return false;
total_bytes -= first_byte;
if (empty_ctor_p)
{
unsigned HOST_WIDE_INT rhs_bytes
= tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (expr)));
if (rhs_bytes > total_bytes)
return false;
memset (ptr + first_byte, '\0', rhs_bytes);
return true;
}
return native_encode_expr (expr, ptr + first_byte, total_bytes) != 0;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* LITTLE-ENDIAN
We are writing a non byte-sized quantity or at a position that is not
at a byte boundary.
|--------|--------|--------| ptr + first_byte
^ ^
xxx xxxxxxxx xxx< bp>
|______EXPR____|
First native_encode_expr EXPR into a temporary buffer and shift each
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
byte in the buffer by 'bp' (carrying the bits over as necessary).
|00000000|00xxxxxx|xxxxxxxx| << bp = |000xxxxx|xxxxxxxx|xxx00000|
<------bitlen---->< bp>
Then we clear the destination bits:
|---00000|00000000|000-----| ptr + first_byte
<-------bitlen--->< bp>
Finally we ORR the bytes of the shifted EXPR into the cleared region:
|---xxxxx||xxxxxxxx||xxx-----| ptr + first_byte.
BIG-ENDIAN
We are writing a non byte-sized quantity or at a position that is not
at a byte boundary.
ptr + first_byte |--------|--------|--------|
^ ^
<bp >xxx xxxxxxxx xxx
|_____EXPR_____|
First native_encode_expr EXPR into a temporary buffer and shift each
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
byte in the buffer to the right by (carrying the bits over as necessary).
We shift by as much as needed to align the most significant bit of EXPR
with bitpos:
|00xxxxxx|xxxxxxxx| >> 3 = |00000xxx|xxxxxxxx|xxxxx000|
<---bitlen----> <bp ><-----bitlen----->
Then we clear the destination bits:
ptr + first_byte |-----000||00000000||00000---|
<bp ><-------bitlen----->
Finally we ORR the bytes of the shifted EXPR into the cleared region:
ptr + first_byte |---xxxxx||xxxxxxxx||xxx-----|.
The awkwardness comes from the fact that bitpos is counted from the
most significant bit of a byte. */
Add a fixed_size_mode class This patch adds a fixed_size_mode machine_mode wrapper for modes that are known to have a fixed size. That applies to all current modes, but future patches will add support for variable-sized modes. The use of this class should be pretty restricted. One important use case is to hold the mode of static data, which can never be variable-sized with current file formats. Another is to hold the modes of registers involved in __builtin_apply and __builtin_result, since those interfaces don't cope well with variable-sized data. The class can also be useful when reinterpreting the contents of a fixed-length bit string as a different kind of value. 2017-11-01 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (fixed_size_mode): New class. * rtl.h (get_pool_mode): Return fixed_size_mode. * gengtype.c (main): Add fixed_size_mode. * target.def (get_raw_result_mode): Return a fixed_size_mode. (get_raw_arg_mode): Likewise. * doc/tm.texi: Regenerate. * targhooks.h (default_get_reg_raw_mode): Return a fixed_size_mode. * targhooks.c (default_get_reg_raw_mode): Likewise. * config/ia64/ia64.c (ia64_get_reg_raw_mode): Likewise. * config/mips/mips.c (mips_get_reg_raw_mode): Likewise. * config/msp430/msp430.c (msp430_get_raw_arg_mode): Likewise. (msp430_get_raw_result_mode): Likewise. * config/avr/avr-protos.h (regmask): Use as_a <fixed_side_mode> * dbxout.c (dbxout_parms): Require fixed-size modes. * expr.c (copy_blkmode_from_reg, copy_blkmode_to_reg): Likewise. * gimple-ssa-store-merging.c (encode_tree_to_bitpos): Likewise. * omp-low.c (lower_oacc_reductions): Likewise. * simplify-rtx.c (simplify_immed_subreg): Take fixed_size_modes. (simplify_subreg): Update accordingly. * varasm.c (constant_descriptor_rtx::mode): Change to fixed_size_mode. (force_const_mem): Update accordingly. Return NULL_RTX for modes that aren't fixed-size. (get_pool_mode): Return a fixed_size_mode. (output_constant_pool_2): Take a fixed_size_mode. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r254300
2017-11-01 12:49:34 +01:00
/* We must be dealing with fixed-size data at this point, since the
total size is also fixed. */
unsigned int byte_size;
if (empty_ctor_p)
{
unsigned HOST_WIDE_INT rhs_bytes
= tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (expr)));
if (rhs_bytes > total_bytes)
return false;
byte_size = rhs_bytes;
}
else
{
fixed_size_mode mode
= as_a <fixed_size_mode> (TYPE_MODE (TREE_TYPE (expr)));
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
byte_size
= mode == BLKmode
? tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (expr)))
: GET_MODE_SIZE (mode);
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Allocate an extra byte so that we have space to shift into. */
byte_size++;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned char *tmpbuf = XALLOCAVEC (unsigned char, byte_size);
memset (tmpbuf, '\0', byte_size);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* The store detection code should only have allowed constants that are
accepted by native_encode_expr or empty ctors. */
if (!empty_ctor_p
&& native_encode_expr (expr, tmpbuf, byte_size - 1) == 0)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gcc_unreachable ();
/* The native_encode_expr machinery uses TYPE_MODE to determine how many
bytes to write. This means it can write more than
ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT bytes (for example
write 8 bytes for a bitlen of 40). Skip the bytes that are not within
bitlen and zero out the bits that are not relevant as well (that may
contain a sign bit due to sign-extension). */
unsigned int padding
= byte_size - ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT - 1;
/* On big-endian the padding is at the 'front' so just skip the initial
bytes. */
if (BYTES_BIG_ENDIAN)
tmpbuf += padding;
byte_size -= padding;
if (bitlen % BITS_PER_UNIT != 0)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
if (BYTES_BIG_ENDIAN)
clear_bit_region_be (tmpbuf, BITS_PER_UNIT - 1,
BITS_PER_UNIT - (bitlen % BITS_PER_UNIT));
else
clear_bit_region (tmpbuf, bitlen,
byte_size * BITS_PER_UNIT - bitlen);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Left shifting relies on the last byte being clear if bitlen is
a multiple of BITS_PER_UNIT, which might not be clear if
there are padding bytes. */
else if (!BYTES_BIG_ENDIAN)
tmpbuf[byte_size - 1] = '\0';
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Clear the bit region in PTR where the bits from TMPBUF will be
inserted into. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (BYTES_BIG_ENDIAN)
clear_bit_region_be (ptr + first_byte,
BITS_PER_UNIT - 1 - (bitpos % BITS_PER_UNIT), bitlen);
else
clear_bit_region (ptr + first_byte, bitpos % BITS_PER_UNIT, bitlen);
int shift_amnt;
int bitlen_mod = bitlen % BITS_PER_UNIT;
int bitpos_mod = bitpos % BITS_PER_UNIT;
bool skip_byte = false;
if (BYTES_BIG_ENDIAN)
{
/* BITPOS and BITLEN are exactly aligned and no shifting
is necessary. */
if (bitpos_mod + bitlen_mod == BITS_PER_UNIT
|| (bitpos_mod == 0 && bitlen_mod == 0))
shift_amnt = 0;
/* |. . . . . . . .|
<bp > <blen >.
We always shift right for BYTES_BIG_ENDIAN so shift the beginning
of the value until it aligns with 'bp' in the next byte over. */
else if (bitpos_mod + bitlen_mod < BITS_PER_UNIT)
{
shift_amnt = bitlen_mod + bitpos_mod;
skip_byte = bitlen_mod != 0;
}
/* |. . . . . . . .|
<----bp--->
<---blen---->.
Shift the value right within the same byte so it aligns with 'bp'. */
else
shift_amnt = bitlen_mod + bitpos_mod - BITS_PER_UNIT;
}
else
shift_amnt = bitpos % BITS_PER_UNIT;
/* Create the shifted version of EXPR. */
if (!BYTES_BIG_ENDIAN)
{
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
shift_bytes_in_array_left (tmpbuf, byte_size, shift_amnt);
if (shift_amnt == 0)
byte_size--;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
else
{
gcc_assert (BYTES_BIG_ENDIAN);
shift_bytes_in_array_right (tmpbuf, byte_size, shift_amnt);
/* If shifting right forced us to move into the next byte skip the now
empty byte. */
if (skip_byte)
{
tmpbuf++;
byte_size--;
}
}
/* Insert the bits from TMPBUF. */
for (unsigned int i = 0; i < byte_size; i++)
ptr[first_byte + i] |= tmpbuf[i];
return true;
}
/* Sorting function for store_immediate_info objects.
Sorts them by bitposition. */
static int
sort_by_bitpos (const void *x, const void *y)
{
store_immediate_info *const *tmp = (store_immediate_info * const *) x;
store_immediate_info *const *tmp2 = (store_immediate_info * const *) y;
if ((*tmp)->bitpos < (*tmp2)->bitpos)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return -1;
else if ((*tmp)->bitpos > (*tmp2)->bitpos)
return 1;
else
/* If they are the same let's use the order which is guaranteed to
be different. */
return (*tmp)->order - (*tmp2)->order;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Sorting function for store_immediate_info objects.
Sorts them by the order field. */
static int
sort_by_order (const void *x, const void *y)
{
store_immediate_info *const *tmp = (store_immediate_info * const *) x;
store_immediate_info *const *tmp2 = (store_immediate_info * const *) y;
if ((*tmp)->order < (*tmp2)->order)
return -1;
else if ((*tmp)->order > (*tmp2)->order)
return 1;
gcc_unreachable ();
}
/* Initialize a merged_store_group object from a store_immediate_info
object. */
merged_store_group::merged_store_group (store_immediate_info *info)
{
start = info->bitpos;
width = info->bitsize;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
bitregion_start = info->bitregion_start;
bitregion_end = info->bitregion_end;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* VAL has memory allocated for it in apply_stores once the group
width has been finalized. */
val = NULL;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
mask = NULL;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
bit_insertion = info->rhs_code == BIT_INSERT_EXPR;
string_concatenation = info->rhs_code == STRING_CST;
only_constants = info->rhs_code == INTEGER_CST;
consecutive = true;
first_nonmergeable_order = ~0U;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
lp_nr = info->lp_nr;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT align_bitpos = 0;
get_object_alignment_1 (gimple_assign_lhs (info->stmt),
&align, &align_bitpos);
align_base = start - align_bitpos;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
for (int i = 0; i < 2; ++i)
{
store_operand_info &op = info->ops[i];
if (op.base_addr == NULL_TREE)
{
load_align[i] = 0;
load_align_base[i] = 0;
}
else
{
get_object_alignment_1 (op.val, &load_align[i], &align_bitpos);
load_align_base[i] = op.bitpos - align_bitpos;
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
stores.create (1);
stores.safe_push (info);
last_stmt = info->stmt;
last_order = info->order;
first_stmt = last_stmt;
first_order = last_order;
buf_size = 0;
}
merged_store_group::~merged_store_group ()
{
if (val)
XDELETEVEC (val);
}
/* Return true if the store described by INFO can be merged into the group. */
bool
merged_store_group::can_be_merged_into (store_immediate_info *info)
{
/* Do not merge bswap patterns. */
if (info->rhs_code == LROTATE_EXPR)
return false;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (info->lp_nr != lp_nr)
return false;
/* The canonical case. */
if (info->rhs_code == stores[0]->rhs_code)
return true;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
/* BIT_INSERT_EXPR is compatible with INTEGER_CST if no STRING_CST. */
if (info->rhs_code == BIT_INSERT_EXPR && stores[0]->rhs_code == INTEGER_CST)
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
return !string_concatenation;
if (stores[0]->rhs_code == BIT_INSERT_EXPR && info->rhs_code == INTEGER_CST)
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
return !string_concatenation;
/* We can turn MEM_REF into BIT_INSERT_EXPR for bit-field stores, but do it
only for small regions since this can generate a lot of instructions. */
if (info->rhs_code == MEM_REF
&& (stores[0]->rhs_code == INTEGER_CST
|| stores[0]->rhs_code == BIT_INSERT_EXPR)
&& info->bitregion_start == stores[0]->bitregion_start
&& info->bitregion_end == stores[0]->bitregion_end
&& info->bitregion_end - info->bitregion_start <= MAX_FIXED_MODE_SIZE)
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
return !string_concatenation;
if (stores[0]->rhs_code == MEM_REF
&& (info->rhs_code == INTEGER_CST
|| info->rhs_code == BIT_INSERT_EXPR)
&& info->bitregion_start == stores[0]->bitregion_start
&& info->bitregion_end == stores[0]->bitregion_end
&& info->bitregion_end - info->bitregion_start <= MAX_FIXED_MODE_SIZE)
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
return !string_concatenation;
/* STRING_CST is compatible with INTEGER_CST if no BIT_INSERT_EXPR. */
if (info->rhs_code == STRING_CST
&& stores[0]->rhs_code == INTEGER_CST
&& stores[0]->bitsize == CHAR_BIT)
return !bit_insertion;
if (stores[0]->rhs_code == STRING_CST
&& info->rhs_code == INTEGER_CST
&& info->bitsize == CHAR_BIT)
return !bit_insertion;
return false;
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Helper method for merge_into and merge_overlapping to do
the common part. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
void
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
merged_store_group::do_merge (store_immediate_info *info)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
bitregion_start = MIN (bitregion_start, info->bitregion_start);
bitregion_end = MAX (bitregion_end, info->bitregion_end);
unsigned int this_align;
unsigned HOST_WIDE_INT align_bitpos = 0;
get_object_alignment_1 (gimple_assign_lhs (info->stmt),
&this_align, &align_bitpos);
if (this_align > align)
{
align = this_align;
align_base = info->bitpos - align_bitpos;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
for (int i = 0; i < 2; ++i)
{
store_operand_info &op = info->ops[i];
if (!op.base_addr)
continue;
get_object_alignment_1 (op.val, &this_align, &align_bitpos);
if (this_align > load_align[i])
{
load_align[i] = this_align;
load_align_base[i] = op.bitpos - align_bitpos;
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple *stmt = info->stmt;
stores.safe_push (info);
if (info->order > last_order)
{
last_order = info->order;
last_stmt = stmt;
}
else if (info->order < first_order)
{
first_order = info->order;
first_stmt = stmt;
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (info->bitpos != start + width)
consecutive = false;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
/* We need to use extraction if there is any bit-field. */
if (info->rhs_code == BIT_INSERT_EXPR)
{
bit_insertion = true;
gcc_assert (!string_concatenation);
}
/* We want to use concatenation if there is any string. */
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (info->rhs_code == STRING_CST)
{
string_concatenation = true;
gcc_assert (!bit_insertion);
}
/* But we cannot use it if we don't have consecutive stores. */
if (!consecutive)
string_concatenation = false;
if (info->rhs_code != INTEGER_CST)
only_constants = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Merge a store recorded by INFO into this merged store.
The store is not overlapping with the existing recorded
stores. */
void
merged_store_group::merge_into (store_immediate_info *info)
{
do_merge (info);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Make sure we're inserting in the position we think we're inserting. */
gcc_assert (info->bitpos >= start + width
&& info->bitregion_start <= bitregion_end);
width = info->bitpos + info->bitsize - start;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Merge a store described by INFO into this merged store.
INFO overlaps in some way with the current store (i.e. it's not contiguous
which is handled by merged_store_group::merge_into). */
void
merged_store_group::merge_overlapping (store_immediate_info *info)
{
do_merge (info);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* If the store extends the size of the group, extend the width. */
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (info->bitpos + info->bitsize > start + width)
width = info->bitpos + info->bitsize - start;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Go through all the recorded stores in this group in program order and
apply their values to the VAL byte array to create the final merged
value. Return true if the operation succeeded. */
bool
merged_store_group::apply_stores ()
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
store_immediate_info *info;
unsigned int i;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Make sure we have more than one store in the group, otherwise we cannot
merge anything. */
if (bitregion_start % BITS_PER_UNIT != 0
|| bitregion_end % BITS_PER_UNIT != 0
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
|| stores.length () == 1)
return false;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
buf_size = (bitregion_end - bitregion_start) / BITS_PER_UNIT;
/* Really do string concatenation for large strings only. */
if (buf_size <= MOVE_MAX)
string_concatenation = false;
/* Create a power-of-2-sized buffer for native_encode_expr. */
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (!string_concatenation)
buf_size = 1 << ceil_log2 (buf_size);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
val = XNEWVEC (unsigned char, 2 * buf_size);
mask = val + buf_size;
memset (val, 0, buf_size);
memset (mask, ~0U, buf_size);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stores.qsort (sort_by_order);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
FOR_EACH_VEC_ELT (stores, i, info)
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned int pos_in_buffer = info->bitpos - bitregion_start;
tree cst;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (info->ops[0].val && info->ops[0].base_addr == NULL_TREE)
cst = info->ops[0].val;
else if (info->ops[1].val && info->ops[1].base_addr == NULL_TREE)
cst = info->ops[1].val;
else
cst = NULL_TREE;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
bool ret = true;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (cst && info->rhs_code != BIT_INSERT_EXPR)
ret = encode_tree_to_bitpos (cst, val, info->bitsize, pos_in_buffer,
buf_size);
unsigned char *m = mask + (pos_in_buffer / BITS_PER_UNIT);
if (BYTES_BIG_ENDIAN)
clear_bit_region_be (m, (BITS_PER_UNIT - 1
- (pos_in_buffer % BITS_PER_UNIT)),
info->bitsize);
else
clear_bit_region (m, pos_in_buffer % BITS_PER_UNIT, info->bitsize);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (cst && dump_file && (dump_flags & TDF_DETAILS))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
if (ret)
{
fputs ("After writing ", dump_file);
Convert dump and optgroup flags to enums gcc/brig/ChangeLog: * brigfrontend/brig-to-generic.cc (brig_to_generic::write_globals): Use TDF_NONE rather than 0. (dump_function): Likewise. gcc/c-family/ChangeLog: * c-pretty-print.c (c_pretty_printer::statement): Use TDF_NONE rather than 0. gcc/ChangeLog: * cfg.c (debug): Use TDF_NONE rather than 0. * cfghooks.c (debug): Likewise. * dumpfile.c (DUMP_FILE_INFO): Likewise; also for OPTGROUP. (struct dump_option_value_info): Convert to... (struct kv_pair): ...this template type. (dump_options): Convert to kv_pair<dump_flags_t>; use TDF_NONE rather than 0. (optinfo_verbosity_options): Likewise. (optgroup_options): Convert to kv_pair<optgroup_flags_t>; use OPTGROUP_NONE. (gcc::dump_manager::dump_register): Use optgroup_flags_t rather than int for "optgroup_flags" param. (dump_generic_expr_loc): Use dump_flags_t rather than int for "dump_kind" param. (dump_dec): Likewise. (dump_finish): Use TDF_NONE rather than 0. (gcc::dump_manager::opt_info_enable_passes): Use optgroup_flags_t rather than int for "optgroup_flags" param. Use TDF_NONE rather than 0. Update for change to option_ptr. (opt_info_switch_p_1): Convert "optgroup_flags" param from int * to optgroup_flags_t *. Use TDF_NONE and OPTGROUP_NONE rather than 0. Update for changes to optinfo_verbosity_options and optgroup_options. (opt_info_switch_p): Convert optgroup_flags from int to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for "dump_kind" param. * dumpfile.h (TDF_ADDRESS, TDF_SLIM, TDF_RAW, TDF_DETAILS, TDF_STATS, TDF_BLOCKS, TDF_VOPS, TDF_LINENO, TDF_UID) TDF_STMTADDR, TDF_GRAPH, TDF_MEMSYMS, TDF_RHS_ONLY, TDF_ASMNAME, TDF_EH, TDF_NOUID, TDF_ALIAS, TDF_ENUMERATE_LOCALS, TDF_CSELIB, TDF_SCEV, TDF_GIMPLE, TDF_FOLDING, MSG_OPTIMIZED_LOCATIONS, MSG_MISSED_OPTIMIZATION, MSG_NOTE, MSG_ALL, TDF_COMPARE_DEBUG, TDF_NONE): Convert from macros to... (enum dump_flag): ...this new enum. (dump_flags_t): Update to use enum. (operator|, operator&, operator~, operator|=, operator&=): Implement for dump_flags_t. (OPTGROUP_NONE, OPTGROUP_IPA, OPTGROUP_LOOP, OPTGROUP_INLINE, OPTGROUP_OMP, OPTGROUP_VEC, OPTGROUP_OTHER, OPTGROUP_ALL): Convert from macros to... (enum optgroup_flag): ...this new enum. (optgroup_flags_t): New typedef. (operator|, operator|=): Implement for optgroup_flags_t. (struct dump_file_info): Convert field "alt_flags" to dump_flags_t. Convert field "optgroup_flags" to optgroup_flags_t. (dump_basic_block): Use dump_flags_t rather than int for param. (dump_generic_expr_loc): Likewise. (dump_dec): Likewise. (dump_register): Convert param "optgroup_flags" to optgroup_flags_t. (opt_info_enable_passes): Likewise. * early-remat.c (early_remat::dump_edge_list): Use TDF_NONE rather than 0. * gimple-pretty-print.c (debug): Likewise. * gimple-ssa-store-merging.c (bswap_replace): Likewise. (merged_store_group::apply_stores): Likewise. * gimple-ssa-strength-reduction.c (insert_initializers): Likewise. * gimple.c (verify_gimple_pp): Likewise. * graphite-poly.c (print_pbb_body): Likewise. * passes.c (pass_manager::register_one_dump_file): Convert local "optgroup_flags" to optgroup_flags_t. * print-tree.c (print_node): Use TDF_NONE rather than 0. (debug): Likewise. (debug_body): Likewise. * tree-pass.h (struct pass_data): Convert field "optgroup_flags" to optgroup_flags_t. * tree-pretty-print.c (print_struct_decl): Use TDF_NONE rather than 0. * tree-ssa-math-opts.c (convert_mult_to_fma_1): Likewise. (convert_mult_to_fma): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-ssa-sccvn.c (vn_eliminate): Likewise. * tree-vect-data-refs.c (dump_lower_bound): Convert param "dump_kind" to dump_flags_t. From-SVN: r261325
2018-06-08 14:50:19 +02:00
print_generic_expr (dump_file, cst, TDF_NONE);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
fprintf (dump_file, " of size " HOST_WIDE_INT_PRINT_DEC
" at position %d\n", info->bitsize, pos_in_buffer);
fputs (" the merged value contains ", dump_file);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
dump_char_array (dump_file, val, buf_size);
fputs (" the merged mask contains ", dump_file);
dump_char_array (dump_file, mask, buf_size);
if (bit_insertion)
fputs (" bit insertion is required\n", dump_file);
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (string_concatenation)
fputs (" string concatenation is required\n", dump_file);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
else
fprintf (dump_file, "Failed to merge stores\n");
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (!ret)
return false;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
stores.qsort (sort_by_bitpos);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return true;
}
/* Structure describing the store chain. */
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
class imm_store_chain_info
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
public:
/* Doubly-linked list that imposes an order on chain processing.
PNXP (prev's next pointer) points to the head of a list, or to
the next field in the previous chain in the list.
See pass_store_merging::m_stores_head for more rationale. */
imm_store_chain_info *next, **pnxp;
tree base_addr;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
auto_vec<store_immediate_info *> m_store_info;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
auto_vec<merged_store_group *> m_merged_store_groups;
imm_store_chain_info (imm_store_chain_info *&inspt, tree b_a)
: next (inspt), pnxp (&inspt), base_addr (b_a)
{
inspt = this;
if (next)
{
gcc_checking_assert (pnxp == next->pnxp);
next->pnxp = &next;
}
}
~imm_store_chain_info ()
{
*pnxp = next;
if (next)
{
gcc_checking_assert (&next == next->pnxp);
next->pnxp = pnxp;
}
}
bool terminate_and_process_chain ();
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
bool try_coalesce_bswap (merged_store_group *, unsigned int, unsigned int,
unsigned int);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
bool coalesce_immediate_stores ();
bool output_merged_store (merged_store_group *);
bool output_merged_stores ();
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
};
const pass_data pass_data_tree_store_merging = {
GIMPLE_PASS, /* type */
"store-merging", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_GIMPLE_STORE_MERGING, /* tv_id */
PROP_ssa, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
TODO_update_ssa, /* todo_flags_finish */
};
class pass_store_merging : public gimple_opt_pass
{
public:
pass_store_merging (gcc::context *ctxt)
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
: gimple_opt_pass (pass_data_tree_store_merging, ctxt), m_stores_head (),
m_n_chains (0), m_n_stores (0)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
}
/* Pass not supported for PDP-endian, nor for insane hosts or
target character sizes where native_{encode,interpret}_expr
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
doesn't work properly. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
virtual bool
gate (function *)
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
return flag_store_merging
&& BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
&& CHAR_BIT == 8
&& BITS_PER_UNIT == 8;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
virtual unsigned int execute (function *);
private:
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
hash_map<tree_operand_hash, class imm_store_chain_info *> m_stores;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Form a doubly-linked stack of the elements of m_stores, so that
we can iterate over them in a predictable way. Using this order
avoids extraneous differences in the compiler output just because
of tree pointer variations (e.g. different chains end up in
different positions of m_stores, so they are handled in different
orders, so they allocate or release SSA names in different
orders, and when they get reused, subsequent passes end up
getting different SSA names, which may ultimately change
decisions when going out of SSA). */
imm_store_chain_info *m_stores_head;
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
/* The number of store chains currently tracked. */
unsigned m_n_chains;
/* The number of stores currently tracked. */
unsigned m_n_stores;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bool process_store (gimple *);
bool terminate_and_process_chain (imm_store_chain_info *);
bool terminate_all_aliasing_chains (imm_store_chain_info **, gimple *);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bool terminate_and_process_all_chains ();
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}; // class pass_store_merging
/* Terminate and process all recorded chains. Return true if any changes
were made. */
bool
pass_store_merging::terminate_and_process_all_chains ()
{
bool ret = false;
while (m_stores_head)
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
ret |= terminate_and_process_chain (m_stores_head);
gcc_assert (m_stores.is_empty ());
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return ret;
}
/* Terminate all chains that are affected by the statement STMT.
CHAIN_INFO is the chain we should ignore from the checks if
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
non-NULL. Return true if any changes were made. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
bool
pass_store_merging::terminate_all_aliasing_chains (imm_store_chain_info
**chain_info,
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple *stmt)
{
bool ret = false;
/* If the statement doesn't touch memory it can't alias. */
if (!gimple_vuse (stmt))
return false;
tree store_lhs = gimple_store_p (stmt) ? gimple_get_lhs (stmt) : NULL_TREE;
ao_ref store_lhs_ref;
ao_ref_init (&store_lhs_ref, store_lhs);
for (imm_store_chain_info *next = m_stores_head, *cur = next; cur; cur = next)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
next = cur->next;
/* We already checked all the stores in chain_info and terminated the
chain if necessary. Skip it here. */
if (chain_info && *chain_info == cur)
continue;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_immediate_info *info;
unsigned int i;
FOR_EACH_VEC_ELT (cur->m_store_info, i, info)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
tree lhs = gimple_assign_lhs (info->stmt);
ao_ref lhs_ref;
ao_ref_init (&lhs_ref, lhs);
if (ref_maybe_used_by_stmt_p (stmt, &lhs_ref)
|| stmt_may_clobber_ref_p_1 (stmt, &lhs_ref)
|| (store_lhs && refs_may_alias_p_1 (&store_lhs_ref,
&lhs_ref, false)))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (dump_file && (dump_flags & TDF_DETAILS))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
fprintf (dump_file, "stmt causes chain termination:\n");
print_gimple_stmt (dump_file, stmt, 0);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
ret |= terminate_and_process_chain (cur);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
break;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
}
}
return ret;
}
/* Helper function. Terminate the recorded chain storing to base object
BASE. Return true if the merging and output was successful. The m_stores
entry is removed after the processing in any case. */
bool
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
pass_store_merging::terminate_and_process_chain (imm_store_chain_info *chain_info)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
m_n_stores -= chain_info->m_store_info.length ();
m_n_chains--;
bool ret = chain_info->terminate_and_process_chain ();
m_stores.remove (chain_info->base_addr);
delete chain_info;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return ret;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Return true if stmts in between FIRST (inclusive) and LAST (exclusive)
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
may clobber REF. FIRST and LAST must have non-NULL vdef. We want to
be able to sink load of REF across stores between FIRST and LAST, up
to right before LAST. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
bool
stmts_may_clobber_ref_p (gimple *first, gimple *last, tree ref)
{
ao_ref r;
ao_ref_init (&r, ref);
unsigned int count = 0;
tree vop = gimple_vdef (last);
gimple *stmt;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
/* Return true conservatively if the basic blocks are different. */
if (gimple_bb (first) != gimple_bb (last))
return true;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
do
{
stmt = SSA_NAME_DEF_STMT (vop);
if (stmt_may_clobber_ref_p_1 (stmt, &r))
return true;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (gimple_store_p (stmt)
&& refs_anti_dependent_p (ref, gimple_get_lhs (stmt)))
return true;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Avoid quadratic compile time by bounding the number of checks
we perform. */
if (++count > MAX_STORE_ALIAS_CHECKS)
return true;
vop = gimple_vuse (stmt);
}
while (stmt != first);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return false;
}
/* Return true if INFO->ops[IDX] is mergeable with the
corresponding loads already in MERGED_STORE group.
BASE_ADDR is the base address of the whole store group. */
bool
compatible_load_p (merged_store_group *merged_store,
store_immediate_info *info,
tree base_addr, int idx)
{
store_immediate_info *infof = merged_store->stores[0];
if (!info->ops[idx].base_addr
|| maybe_ne (info->ops[idx].bitpos - infof->ops[idx].bitpos,
info->bitpos - infof->bitpos)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
|| !operand_equal_p (info->ops[idx].base_addr,
infof->ops[idx].base_addr, 0))
return false;
store_immediate_info *infol = merged_store->stores.last ();
tree load_vuse = gimple_vuse (info->ops[idx].stmt);
/* In this case all vuses should be the same, e.g.
_1 = s.a; _2 = s.b; _3 = _1 | 1; t.a = _3; _4 = _2 | 2; t.b = _4;
or
_1 = s.a; _2 = s.b; t.a = _1; t.b = _2;
and we can emit the coalesced load next to any of those loads. */
if (gimple_vuse (infof->ops[idx].stmt) == load_vuse
&& gimple_vuse (infol->ops[idx].stmt) == load_vuse)
return true;
/* Otherwise, at least for now require that the load has the same
vuse as the store. See following examples. */
if (gimple_vuse (info->stmt) != load_vuse)
return false;
if (gimple_vuse (infof->stmt) != gimple_vuse (infof->ops[idx].stmt)
|| (infof != infol
&& gimple_vuse (infol->stmt) != gimple_vuse (infol->ops[idx].stmt)))
return false;
/* If the load is from the same location as the store, already
the construction of the immediate chain info guarantees no intervening
stores, so no further checks are needed. Example:
_1 = s.a; _2 = _1 & -7; s.a = _2; _3 = s.b; _4 = _3 & -7; s.b = _4; */
if (known_eq (info->ops[idx].bitpos, info->bitpos)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
&& operand_equal_p (info->ops[idx].base_addr, base_addr, 0))
return true;
/* Otherwise, we need to punt if any of the loads can be clobbered by any
of the stores in the group, or any other stores in between those.
Previous calls to compatible_load_p ensured that for all the
merged_store->stores IDX loads, no stmts starting with
merged_store->first_stmt and ending right before merged_store->last_stmt
clobbers those loads. */
gimple *first = merged_store->first_stmt;
gimple *last = merged_store->last_stmt;
/* The stores are sorted by increasing store bitpos, so if info->stmt store
comes before the so far first load, we'll be changing
merged_store->first_stmt. In that case we need to give up if
any of the earlier processed loads clobber with the stmts in the new
range. */
if (info->order < merged_store->first_order)
{
use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org> gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise.
2021-06-12 05:49:22 +02:00
for (store_immediate_info *infoc : merged_store->stores)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (stmts_may_clobber_ref_p (info->stmt, first, infoc->ops[idx].val))
return false;
first = info->stmt;
}
/* Similarly, we could change merged_store->last_stmt, so ensure
in that case no stmts in the new range clobber any of the earlier
processed loads. */
else if (info->order > merged_store->last_order)
{
use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org> gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise.
2021-06-12 05:49:22 +02:00
for (store_immediate_info *infoc : merged_store->stores)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (stmts_may_clobber_ref_p (last, info->stmt, infoc->ops[idx].val))
return false;
last = info->stmt;
}
/* And finally, we'd be adding a new load to the set, ensure it isn't
clobbered in the new range. */
if (stmts_may_clobber_ref_p (first, last, info->ops[idx].val))
return false;
/* Otherwise, we are looking for:
_1 = s.a; _2 = _1 ^ 15; t.a = _2; _3 = s.b; _4 = _3 ^ 15; t.b = _4;
or
_1 = s.a; t.a = _1; _2 = s.b; t.b = _2; */
return true;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Add all refs loaded to compute VAL to REFS vector. */
void
gather_bswap_load_refs (vec<tree> *refs, tree val)
{
if (TREE_CODE (val) != SSA_NAME)
return;
gimple *stmt = SSA_NAME_DEF_STMT (val);
if (!is_gimple_assign (stmt))
return;
if (gimple_assign_load_p (stmt))
{
refs->safe_push (gimple_assign_rhs1 (stmt));
return;
}
switch (gimple_assign_rhs_class (stmt))
{
case GIMPLE_BINARY_RHS:
gather_bswap_load_refs (refs, gimple_assign_rhs2 (stmt));
/* FALLTHRU */
case GIMPLE_UNARY_RHS:
gather_bswap_load_refs (refs, gimple_assign_rhs1 (stmt));
break;
default:
gcc_unreachable ();
}
}
/* Check if there are any stores in M_STORE_INFO after index I
(where M_STORE_INFO must be sorted by sort_by_bitpos) that overlap
a potential group ending with END that have their order
store-merging: Fix coalesce_immediate_stores [PR93820] The following testcase is miscompiled in 8+. The problem is that check_no_overlap has a special case for INTEGER_CST marked stores (i.e. stores of constants), if both all currenly merged stores and the one under consideration for merging with them are marked that way, it anticipates that other INTEGER_CST marked stores that overlap with those and precede those (have smaller info->order) could be merged with those and doesn't punt for them. In PR86844 and PR87859 fixes I've then added quite large code that is performed after check_no_overlap and tries to find out if we need and can merge further INTEGER_CST marked stores, or need to punt. Unfortunately, that code is there only in the overlapping case code and the testcase below shows that we really need it even in the adjacent store case. After sort_by_bitpos we have: bitpos width order rhs_code 96 32 3 INTEGER_CST 128 32 1 INTEGER_CST 128 128 2 INTEGER_CST 192 32 0 MEM_REF Because of the missing PR86844/PR87859-ish code in the adjacent store case, we merge the adjacent (memory wise) stores 96/32/3 and 128/32/1, and then we consider the 128-bit store which is in program-order in between them, but in this case we punt, because the merging would extend the merged store region from bitpos 96 and 64-bits to bitpos 96 and 160-bits and that has an overlap with an incompatible store (the MEM_REF one). The problem is that we can't really punt this way, because the 128-bit store is in between those two we've merged already, so either we manage to merge even that one together with the others, or would need to avoid already merging the 96/32/3 and 128/32/1 stores together. Now, rather than copying around the PR86844/PR87859 code to the other spot, we can actually just use the overlapping code, merge_overlapping is really a superset of merge_into, so that is what the patch does. If doing adjacent store merge for rhs_code other than INTEGER_CST, I believe the current code is already fine, check_no_overlap in that case doesn't make the exception and will punt if there is some earlier (smaller order) non-mergeable overlapping store. There is just one case that could be problematic, if the merged_store has BIT_INSERT_EXPRs in them and the new store is a constant store (INTEGER_CST rhs_code), then check_no_overlap would do the exception and still would allow the special case. But we really shouldn't have the special case in that case, so this patch also changes check_no_overlap to just have a bool whether we should have the special case or not. Note, as I said in the PR, for GCC11 we could consider performing some kind of cheap DSE during the store merging (perhaps guarded with flag_tree_dse). And another thing to consider is only consider as problematic non-mergeable stores that not only have order smaller than last_order as currently, but also have order larger than first_order, as in this testcase if we actually ignored (not merged with anything at all) the 192/32/0 store, because it is not in between the other stores we'd merge, it would be fine to merge the other 3 stores, though of course the testcase can be easily adjusted by putting the 192/32 store after the 128/32 store and then this patch would be still needed. Though, I think I'd need more time thinking this over. 2020-02-26 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93820 * gimple-ssa-store-merging.c (check_no_overlap): Change RHS_CODE argument to ALL_INTEGER_CST_P boolean. (imm_store_chain_info::try_coalesce_bswap): Adjust caller. (imm_store_chain_info::coalesce_immediate_stores): Likewise. Handle adjacent INTEGER_CST store into merged_store->only_constants like overlapping one. * gcc.dg/pr93820.c: New test.
2020-02-26 09:33:48 +01:00
smaller than LAST_ORDER. ALL_INTEGER_CST_P is true if
all the stores already merged and the one under consideration
have rhs_code of INTEGER_CST. Return true if there are no such stores.
Consider:
MEM[(long long int *)p_28] = 0;
MEM[(long long int *)p_28 + 8B] = 0;
MEM[(long long int *)p_28 + 16B] = 0;
MEM[(long long int *)p_28 + 24B] = 0;
_129 = (int) _130;
MEM[(int *)p_28 + 8B] = _129;
MEM[(int *)p_28].a = -1;
We already have
MEM[(long long int *)p_28] = 0;
MEM[(int *)p_28].a = -1;
stmts in the current group and need to consider if it is safe to
add MEM[(long long int *)p_28 + 8B] = 0; store into the same group.
There is an overlap between that store and the MEM[(int *)p_28 + 8B] = _129;
store though, so if we add the MEM[(long long int *)p_28 + 8B] = 0;
into the group and merging of those 3 stores is successful, merged
stmts will be emitted at the latest store from that group, i.e.
LAST_ORDER, which is the MEM[(int *)p_28].a = -1; store.
The MEM[(int *)p_28 + 8B] = _129; store that originally follows
the MEM[(long long int *)p_28 + 8B] = 0; would now be before it,
so we need to refuse merging MEM[(long long int *)p_28 + 8B] = 0;
into the group. That way it will be its own store group and will
store-merging: Fix coalesce_immediate_stores [PR93820] The following testcase is miscompiled in 8+. The problem is that check_no_overlap has a special case for INTEGER_CST marked stores (i.e. stores of constants), if both all currenly merged stores and the one under consideration for merging with them are marked that way, it anticipates that other INTEGER_CST marked stores that overlap with those and precede those (have smaller info->order) could be merged with those and doesn't punt for them. In PR86844 and PR87859 fixes I've then added quite large code that is performed after check_no_overlap and tries to find out if we need and can merge further INTEGER_CST marked stores, or need to punt. Unfortunately, that code is there only in the overlapping case code and the testcase below shows that we really need it even in the adjacent store case. After sort_by_bitpos we have: bitpos width order rhs_code 96 32 3 INTEGER_CST 128 32 1 INTEGER_CST 128 128 2 INTEGER_CST 192 32 0 MEM_REF Because of the missing PR86844/PR87859-ish code in the adjacent store case, we merge the adjacent (memory wise) stores 96/32/3 and 128/32/1, and then we consider the 128-bit store which is in program-order in between them, but in this case we punt, because the merging would extend the merged store region from bitpos 96 and 64-bits to bitpos 96 and 160-bits and that has an overlap with an incompatible store (the MEM_REF one). The problem is that we can't really punt this way, because the 128-bit store is in between those two we've merged already, so either we manage to merge even that one together with the others, or would need to avoid already merging the 96/32/3 and 128/32/1 stores together. Now, rather than copying around the PR86844/PR87859 code to the other spot, we can actually just use the overlapping code, merge_overlapping is really a superset of merge_into, so that is what the patch does. If doing adjacent store merge for rhs_code other than INTEGER_CST, I believe the current code is already fine, check_no_overlap in that case doesn't make the exception and will punt if there is some earlier (smaller order) non-mergeable overlapping store. There is just one case that could be problematic, if the merged_store has BIT_INSERT_EXPRs in them and the new store is a constant store (INTEGER_CST rhs_code), then check_no_overlap would do the exception and still would allow the special case. But we really shouldn't have the special case in that case, so this patch also changes check_no_overlap to just have a bool whether we should have the special case or not. Note, as I said in the PR, for GCC11 we could consider performing some kind of cheap DSE during the store merging (perhaps guarded with flag_tree_dse). And another thing to consider is only consider as problematic non-mergeable stores that not only have order smaller than last_order as currently, but also have order larger than first_order, as in this testcase if we actually ignored (not merged with anything at all) the 192/32/0 store, because it is not in between the other stores we'd merge, it would be fine to merge the other 3 stores, though of course the testcase can be easily adjusted by putting the 192/32 store after the 128/32 store and then this patch would be still needed. Though, I think I'd need more time thinking this over. 2020-02-26 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93820 * gimple-ssa-store-merging.c (check_no_overlap): Change RHS_CODE argument to ALL_INTEGER_CST_P boolean. (imm_store_chain_info::try_coalesce_bswap): Adjust caller. (imm_store_chain_info::coalesce_immediate_stores): Likewise. Handle adjacent INTEGER_CST store into merged_store->only_constants like overlapping one. * gcc.dg/pr93820.c: New test.
2020-02-26 09:33:48 +01:00
not be touched. If ALL_INTEGER_CST_P and there are overlapping
INTEGER_CST stores, those are mergeable using merge_overlapping,
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
so don't return false for those.
Similarly, check stores from FIRST_EARLIER (inclusive) to END_EARLIER
(exclusive), whether they don't overlap the bitrange START to END
and have order in between FIRST_ORDER and LAST_ORDER. This is to
prevent merging in cases like:
MEM <char[12]> [&b + 8B] = {};
MEM[(short *) &b] = 5;
_5 = *x_4(D);
MEM <long long unsigned int> [&b + 2B] = _5;
MEM[(char *)&b + 16B] = 88;
MEM[(int *)&b + 20B] = 1;
The = {} store comes in sort_by_bitpos before the = 88 store, and can't
be merged with it, because the = _5 store overlaps these and is in between
them in sort_by_order ordering. If it was merged, the merged store would
go after the = _5 store and thus change behavior. */
static bool
Adjust by-value function vec arguments to by-reference. gcc/c-family/ChangeLog: * c-common.c (c_build_shufflevector): Adjust by-value argument to by-const-reference. * c-common.h (c_build_shufflevector): Same. gcc/c/ChangeLog: * c-tree.h (c_build_function_call_vec): Adjust by-value argument to by-const-reference. * c-typeck.c (c_build_function_call_vec): Same. gcc/ChangeLog: * cfgloop.h (single_likely_exit): Adjust by-value argument to by-const-reference. * cfgloopanal.c (single_likely_exit): Same. * cgraph.h (struct cgraph_node): Same. * cgraphclones.c (cgraph_node::create_virtual_clone): Same. * genautomata.c (merge_states): Same. * genextract.c (VEC_char_to_string): Same. * genmatch.c (dt_node::gen_kids_1): Same. (walk_captures): Adjust by-value argument to by-reference. * gimple-ssa-store-merging.c (check_no_overlap): Adjust by-value argument to by-const-reference. * gimple.c (gimple_build_call_vec): Same. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * gimple.h (gimple_build_call_vec): Adjust by-value argument to by-const-reference. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * haifa-sched.c (calc_priorities): Adjust by-value argument to by-const-reference. (sched_init_luids): Same. (haifa_init_h_i_d): Same. * ipa-cp.c (ipa_get_indirect_edge_target_1): Same. (adjust_callers_for_value_intersection): Adjust by-value argument to by-reference. (find_more_scalar_values_for_callers_subset): Adjust by-value argument to by-const-reference. (find_more_contexts_for_caller_subset): Same. (find_aggregate_values_for_callers_subset): Same. (copy_useful_known_contexts): Same. * ipa-fnsummary.c (remap_edge_summaries): Same. (remap_freqcounting_predicate): Same. * ipa-inline.c (add_new_edges_to_heap): Adjust by-value argument to by-reference. * ipa-predicate.c (predicate::remap_after_inlining): Adjust by-value argument to by-const-reference. * ipa-predicate.h (predicate::remap_after_inlining): Same. * ipa-prop.c (ipa_find_agg_cst_for_param): Same. * ipa-prop.h (ipa_find_agg_cst_for_param): Same. * ira-build.c (ira_loop_tree_body_rev_postorder): Same. * read-rtl.c (add_overload_instance): Same. * rtl.h (native_decode_rtx): Same. (native_decode_vector_rtx): Same. * sched-int.h (sched_init_luids): Same. (haifa_init_h_i_d): Same. * simplify-rtx.c (native_decode_vector_rtx): Same. (native_decode_rtx): Same. * tree-call-cdce.c (gen_shrink_wrap_conditions): Same. (shrink_wrap_one_built_in_call_with_conds): Same. (shrink_wrap_conditional_dead_built_in_calls): Same. * tree-data-ref.c (create_runtime_alias_checks): Same. (compute_all_dependences): Same. * tree-data-ref.h (compute_all_dependences): Same. (create_runtime_alias_checks): Same. (index_in_loop_nest): Same. * tree-if-conv.c (mask_exists): Same. * tree-loop-distribution.c (class loop_distribution): Same. (loop_distribution::create_rdg_vertices): Same. (dump_rdg_partitions): Same. (debug_rdg_partitions): Same. (partition_contains_all_rw): Same. (loop_distribution::distribute_loop): Same. * tree-parloops.c (oacc_entry_exit_ok_1): Same. (oacc_entry_exit_single_gang): Same. * tree-ssa-loop-im.c (hoist_memory_references): Same. (loop_suitable_for_sm): Same. * tree-ssa-loop-niter.c (bound_index): Same. * tree-ssa-reassoc.c (update_ops): Same. (swap_ops_for_binary_stmt): Same. (rewrite_expr_tree): Same. (rewrite_expr_tree_parallel): Same. * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Same. * tree-ssa-sccvn.h (ao_ref_init_from_vn_reference): Same. * tree-ssa-structalias.c (process_all_all_constraints): Same. (make_constraints_to): Same. (handle_lhs_call): Same. (find_func_aliases_for_builtin_call): Same. (sort_fieldstack): Same. (check_for_overlaps): Same. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Same. (vect_create_cond_for_unequal_addrs): Same. (vect_create_cond_for_lower_bounds): Same. (vect_create_cond_for_alias_checks): Same. * tree-vect-slp-patterns.c (vect_validate_multiplication): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. (vect_make_slp_decision): Same. (vect_slp_bbs): Same. (duplicate_and_interleave): Same. (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. * tree-vectorizer.h (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. (duplicate_and_interleave): Same. * tree.c (build_vector_from_ctor): Same. (build_vector): Same. (check_vector_cst): Same. (check_vector_cst_duplicate): Same. (check_vector_cst_fill): Same. (check_vector_cst_stepped): Same. * tree.h (build_vector_from_ctor): Same.
2021-07-20 19:14:19 +02:00
check_no_overlap (const vec<store_immediate_info *> &m_store_info,
unsigned int i,
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
bool all_integer_cst_p, unsigned int first_order,
unsigned int last_order, unsigned HOST_WIDE_INT start,
unsigned HOST_WIDE_INT end, unsigned int first_earlier,
unsigned end_earlier)
{
unsigned int len = m_store_info.length ();
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
for (unsigned int j = first_earlier; j < end_earlier; j++)
{
store_immediate_info *info = m_store_info[j];
if (info->order > first_order
&& info->order < last_order
&& info->bitpos + info->bitsize > start)
return false;
}
for (++i; i < len; ++i)
{
store_immediate_info *info = m_store_info[i];
if (info->bitpos >= end)
break;
if (info->order < last_order
store-merging: Fix coalesce_immediate_stores [PR93820] The following testcase is miscompiled in 8+. The problem is that check_no_overlap has a special case for INTEGER_CST marked stores (i.e. stores of constants), if both all currenly merged stores and the one under consideration for merging with them are marked that way, it anticipates that other INTEGER_CST marked stores that overlap with those and precede those (have smaller info->order) could be merged with those and doesn't punt for them. In PR86844 and PR87859 fixes I've then added quite large code that is performed after check_no_overlap and tries to find out if we need and can merge further INTEGER_CST marked stores, or need to punt. Unfortunately, that code is there only in the overlapping case code and the testcase below shows that we really need it even in the adjacent store case. After sort_by_bitpos we have: bitpos width order rhs_code 96 32 3 INTEGER_CST 128 32 1 INTEGER_CST 128 128 2 INTEGER_CST 192 32 0 MEM_REF Because of the missing PR86844/PR87859-ish code in the adjacent store case, we merge the adjacent (memory wise) stores 96/32/3 and 128/32/1, and then we consider the 128-bit store which is in program-order in between them, but in this case we punt, because the merging would extend the merged store region from bitpos 96 and 64-bits to bitpos 96 and 160-bits and that has an overlap with an incompatible store (the MEM_REF one). The problem is that we can't really punt this way, because the 128-bit store is in between those two we've merged already, so either we manage to merge even that one together with the others, or would need to avoid already merging the 96/32/3 and 128/32/1 stores together. Now, rather than copying around the PR86844/PR87859 code to the other spot, we can actually just use the overlapping code, merge_overlapping is really a superset of merge_into, so that is what the patch does. If doing adjacent store merge for rhs_code other than INTEGER_CST, I believe the current code is already fine, check_no_overlap in that case doesn't make the exception and will punt if there is some earlier (smaller order) non-mergeable overlapping store. There is just one case that could be problematic, if the merged_store has BIT_INSERT_EXPRs in them and the new store is a constant store (INTEGER_CST rhs_code), then check_no_overlap would do the exception and still would allow the special case. But we really shouldn't have the special case in that case, so this patch also changes check_no_overlap to just have a bool whether we should have the special case or not. Note, as I said in the PR, for GCC11 we could consider performing some kind of cheap DSE during the store merging (perhaps guarded with flag_tree_dse). And another thing to consider is only consider as problematic non-mergeable stores that not only have order smaller than last_order as currently, but also have order larger than first_order, as in this testcase if we actually ignored (not merged with anything at all) the 192/32/0 store, because it is not in between the other stores we'd merge, it would be fine to merge the other 3 stores, though of course the testcase can be easily adjusted by putting the 192/32 store after the 128/32 store and then this patch would be still needed. Though, I think I'd need more time thinking this over. 2020-02-26 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93820 * gimple-ssa-store-merging.c (check_no_overlap): Change RHS_CODE argument to ALL_INTEGER_CST_P boolean. (imm_store_chain_info::try_coalesce_bswap): Adjust caller. (imm_store_chain_info::coalesce_immediate_stores): Likewise. Handle adjacent INTEGER_CST store into merged_store->only_constants like overlapping one. * gcc.dg/pr93820.c: New test.
2020-02-26 09:33:48 +01:00
&& (!all_integer_cst_p || info->rhs_code != INTEGER_CST))
return false;
}
return true;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Return true if m_store_info[first] and at least one following store
form a group which store try_size bitsize value which is byte swapped
from a memory load or some value, or identity from some value.
This uses the bswap pass APIs. */
bool
imm_store_chain_info::try_coalesce_bswap (merged_store_group *merged_store,
unsigned int first,
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
unsigned int try_size,
unsigned int first_earlier)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
unsigned int len = m_store_info.length (), last = first;
unsigned HOST_WIDE_INT width = m_store_info[first]->bitsize;
if (width >= try_size)
return false;
for (unsigned int i = first + 1; i < len; ++i)
{
if (m_store_info[i]->bitpos != m_store_info[first]->bitpos + width
|| m_store_info[i]->lp_nr != merged_store->lp_nr
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
|| m_store_info[i]->ins_stmt == NULL)
return false;
width += m_store_info[i]->bitsize;
if (width >= try_size)
{
last = i;
break;
}
}
if (width != try_size)
return false;
bool allow_unaligned
Apply mechanical replacement (generated patch). 2019-11-12 Martin Liska <mliska@suse.cz> * asan.c (asan_sanitize_stack_p): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. (asan_sanitize_allocas_p): Likewise. (asan_emit_stack_protection): Likewise. (asan_protect_global): Likewise. (instrument_derefs): Likewise. (instrument_builtin_call): Likewise. (asan_expand_mark_ifn): Likewise. * auto-profile.c (auto_profile): Likewise. * bb-reorder.c (copy_bb_p): Likewise. (duplicate_computed_gotos): Likewise. * builtins.c (inline_expand_builtin_string_cmp): Likewise. * cfgcleanup.c (try_crossjump_to_edge): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.c (defer_stack_allocation): Likewise. (stack_protect_classify_type): Likewise. (pass_expand::execute): Likewise. * cfgloopanal.c (expected_loop_iterations_unbounded): Likewise. (estimate_reg_pressure_cost): Likewise. * cgraph.c (cgraph_edge::maybe_hot_p): Likewise. * combine.c (combine_instructions): Likewise. (record_value_for_reg): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_option_validate_param): Likewise. (aarch64_option_default_params): Likewise. * common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise. * common/config/sh/sh-common.c (sh_option_default_params): Likewise. * config/aarch64/aarch64.c (aarch64_output_probe_stack_range): Likewise. (aarch64_allocate_and_probe_stack_space): Likewise. (aarch64_expand_epilogue): Likewise. (aarch64_override_options_internal): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arm/arm.c (arm_option_override): Likewise. (arm_valid_target_attribute_p): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (get_probe_interval): Likewise. (ix86_adjust_stack_and_probe_stack_clash): Likewise. (ix86_max_noce_ifcvt_seq_cost): Likewise. * config/ia64/ia64.c (ia64_adjust_cost): Likewise. * config/rs6000/rs6000-logue.c (get_stack_clash_protection_probe_interval): Likewise. (get_stack_clash_protection_guard_size): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/s390/s390.c (allocate_stack_space): Likewise. (s390_emit_prologue): Likewise. (s390_option_override_internal): Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/visium/visium.c (visium_option_override): Likewise. * coverage.c (get_coverage_counts): Likewise. (coverage_compute_profile_id): Likewise. (coverage_begin_function): Likewise. (coverage_end_function): Likewise. * cse.c (cse_find_path): Likewise. (cse_extended_basic_block): Likewise. (cse_main): Likewise. * cselib.c (cselib_invalidate_mem): Likewise. * dse.c (dse_step1): Likewise. * emit-rtl.c (set_new_first_and_last_insn): Likewise. (get_max_insn_count): Likewise. (make_debug_insn_raw): Likewise. (init_emit): Likewise. * explow.c (compute_stack_clash_protection_loop_data): Likewise. * final.c (compute_alignments): Likewise. * fold-const.c (fold_range_test): Likewise. (fold_truth_andor): Likewise. (tree_single_nonnegative_warnv_p): Likewise. (integer_valued_real_single_p): Likewise. * gcse.c (want_to_gcse_p): Likewise. (prune_insertions_deletions): Likewise. (hoist_code): Likewise. (gcse_or_cprop_is_too_expensive): Likewise. * ggc-common.c: Likewise. * ggc-page.c (ggc_collect): Likewise. * gimple-loop-interchange.cc (MAX_NUM_STMT): Likewise. (MAX_DATAREFS): Likewise. (OUTER_STRIDE_RATIO): Likewise. * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise. * gimple-loop-versioning.cc (loop_versioning::max_insns_for_loop): Likewise. * gimple-ssa-split-paths.c (is_feasible_trace): Likewise. * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (imm_store_chain_info::output_merged_store): Likewise. (pass_store_merging::process_store): Likewise. * gimple-ssa-strength-reduction.c (find_basis_for_base_expr): Likewise. * graphite-isl-ast-to-gimple.c (class translate_isl_ast_to_gimple): Likewise. (scop_to_isl_ast): Likewise. * graphite-optimize-isl.c (get_schedule_for_node_st): Likewise. (optimize_isl): Likewise. * graphite-scop-detection.c (build_scops): Likewise. * haifa-sched.c (set_modulo_params): Likewise. (rank_for_schedule): Likewise. (model_add_to_worklist): Likewise. (model_promote_insn): Likewise. (model_choose_insn): Likewise. (queue_to_ready): Likewise. (autopref_multipass_dfa_lookahead_guard): Likewise. (schedule_block): Likewise. (sched_init): Likewise. * hsa-gen.c (init_prologue): Likewise. * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Likewise. (cond_move_process_if_block): Likewise. * ipa-cp.c (ipcp_lattice::add_value): Likewise. (merge_agg_lats_step): Likewise. (devirtualization_time_bonus): Likewise. (hint_time_bonus): Likewise. (incorporate_penalties): Likewise. (good_cloning_opportunity_p): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (decompose_param_expr): Likewise. (set_switch_stmt_execution_predicate): Likewise. (analyze_function_body): Likewise. (compute_fn_summary): Likewise. * ipa-inline-analysis.c (estimate_growth): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (inline_insns_single): Likewise. (inline_insns_auto): Likewise. (can_inline_edge_by_limits_p): Likewise. (want_early_inline_function_p): Likewise. (big_speedup_p): Likewise. (want_inline_small_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (edge_badness): Likewise. (recursive_inlining): Likewise. (compute_max_insns): Likewise. (early_inliner): Likewise. * ipa-polymorphic-call.c (csftc_abort_walking_p): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (determine_known_aggregate_parts): Likewise. (ipa_analyze_node): Likewise. (ipcp_transform_function): Likewise. * ipa-split.c (consider_split): Likewise. * ipa-sra.c (allocate_access): Likewise. (process_scan_results): Likewise. (ipa_sra_summarize_function): Likewise. (pull_accesses_from_callee): Likewise. * ira-build.c (loop_compare_func): Likewise. (mark_loops_for_removal): Likewise. * ira-conflicts.c (build_conflict_bit_table): Likewise. * loop-doloop.c (doloop_optimize): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. (move_loop_invariants): Likewise. * loop-unroll.c (decide_unroll_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. (expand_var_during_unrolling): Likewise. * lra-assigns.c (spill_for): Likewise. * lra-constraints.c (EBB_PROBABILITY_CUTOFF): Likewise. * modulo-sched.c (sms_schedule): Likewise. (DFA_HISTORY): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (common_handle_option): Likewise. * postreload-gcse.c (eliminate_partially_redundant_load): Likewise. (if): Likewise. * predict.c (get_hot_bb_threshold): Likewise. (maybe_hot_count_p): Likewise. (probably_never_executed): Likewise. (predictable_edge_p): Likewise. (predict_loops): Likewise. (expr_expected_value_1): Likewise. (tree_predict_by_opcode): Likewise. (handle_missing_profiles): Likewise. * reload.c (find_equiv_reg): Likewise. * reorg.c (redundant_insn): Likewise. * resource.c (mark_target_live_regs): Likewise. (incr_ticks_for_insn): Likewise. * sanopt.c (pass_sanopt::execute): Likewise. * sched-deps.c (sched_analyze_1): Likewise. (sched_analyze_2): Likewise. (sched_analyze_insn): Likewise. (deps_analyze_insn): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (find_single_block_region): Likewise. (too_large): Likewise. (haifa_find_rgns): Likewise. (extend_rgns): Likewise. (new_ready): Likewise. (schedule_region): Likewise. (sched_rgn_init): Likewise. * sel-sched-ir.c (make_region_from_loop): Likewise. * sel-sched-ir.h (MAX_WS): Likewise. * sel-sched.c (process_pipelined_exprs): Likewise. (sel_setup_region_sched_flags): Likewise. * shrink-wrap.c (try_shrink_wrapping): Likewise. * targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise. * toplev.c (print_version): Likewise. (process_options): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_log_add): Likewise. * tree-chrec.c (chrec_fold_plus_1): Likewise. * tree-data-ref.c (split_constant_offset): Likewise. (compute_all_dependences): Likewise. * tree-if-conv.c (MAX_PHI_ARG_NUM): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. * tree-loop-distribution.c (MAX_DATAREFS_NUM): Likewise. * tree-parloops.c (MIN_PER_THREAD): Likewise. (create_parallel_loop): Likewise. * tree-predcom.c (determine_unroll_factor): Likewise. * tree-scalar-evolution.c (instantiate_scev_r): Likewise. * tree-sra.c (analyze_all_variable_accesses): Likewise. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Likewise. * tree-ssa-dse.c (setup_live_bytes_from_ref): Likewise. (dse_optimize_redundant_stores): Likewise. (dse_classify_store): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise. * tree-ssa-loop-im.c (LIM_EXPENSIVE): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise. (CONSIDER_ALL_CANDIDATES_BOUND): Likewise. (MAX_CONSIDERED_GROUPS): Likewise. (ALWAYS_PRUNE_CAND_SET_BOUND): Likewise. * tree-ssa-loop-manip.c (can_unroll_loop_p): Likewise. * tree-ssa-loop-niter.c (MAX_ITERATIONS_TO_TRACK): Likewise. * tree-ssa-loop-prefetch.c (PREFETCH_BLOCK): Likewise. (L1_CACHE_SIZE_BYTES): Likewise. (L2_CACHE_SIZE_BYTES): Likewise. (should_issue_prefetch_p): Likewise. (schedule_prefetches): Likewise. (determine_unroll_factor): Likewise. (volume_of_references): Likewise. (add_subscript_strides): Likewise. (self_reuse_distance): Likewise. (mem_ref_count_reasonable_p): Likewise. (insn_to_prefetch_ratio_too_small_p): Likewise. (loop_prefetch_arrays): Likewise. (tree_ssa_prefetch_arrays): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. (convert_mult_to_fma): Likewise. (math_opts_dom_walker::after_dom_children): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. (hoist_adjacent_loads): Likewise. (gate_hoist_loads): Likewise. * tree-ssa-pre.c (translate_vuse_through_block): Likewise. (compute_partial_antic_aux): Likewise. * tree-ssa-reassoc.c (get_reassociation_width): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. (do_rpo_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. * tree-ssa-sink.c (select_best_block): Likewise. * tree-ssa-strlen.c (new_stridx): Likewise. (new_addr_stridx): Likewise. (get_range_strlen_dynamic): Likewise. (class ssa_name_limit_t): Likewise. * tree-ssa-structalias.c (push_fields_onto_fieldstack): Likewise. (create_variable_info_for_1): Likewise. (init_alias_vars): Likewise. * tree-ssa-tail-merge.c (find_clusters_1): Likewise. (tail_merge_optimize): Likewise. * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Likewise. (thread_jumps::fsm_find_control_statement_thread_paths): Likewise. (thread_jumps::find_jump_threads_backwards): Likewise. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Likewise. * tree-ssa-uninit.c (compute_control_dep_chain): Likewise. * tree-switch-conversion.c (switch_conversion::check_range): Likewise. (jump_table_cluster::can_be_handled): Likewise. * tree-switch-conversion.h (jump_table_cluster::case_values_threshold): Likewise. (SWITCH_CONVERSION_BRANCH_RATIO): Likewise. (param_switch_conversion_branch_ratio): Likewise. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_analyze_loop_costing): Likewise. (vect_get_datarefs_in_loop): Likewise. (vect_analyze_loop): Likewise. * tree-vect-slp.c (vect_slp_bb): Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (vrp_prop::check_mem_ref): Likewise. * tree.c (wide_int_to_tree_1): Likewise. (cache_integer_cst): Likewise. * var-tracking.c (EXPR_USE_DEPTH): Likewise. (reverse_op): Likewise. (vt_find_locations): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_parse_gimple_body): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_hints::namespace_hints): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * typeck.c (comptypes): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-partition.c (lto_balanced_map): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * lto.c (do_whole_program_analysis): Likewise. From-SVN: r278085
2019-11-12 11:08:40 +01:00
= !STRICT_ALIGNMENT && param_store_merging_allow_unaligned;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Punt if the combined store would not be aligned and we need alignment. */
if (!allow_unaligned)
{
unsigned int align = merged_store->align;
unsigned HOST_WIDE_INT align_base = merged_store->align_base;
for (unsigned int i = first + 1; i <= last; ++i)
{
unsigned int this_align;
unsigned HOST_WIDE_INT align_bitpos = 0;
get_object_alignment_1 (gimple_assign_lhs (m_store_info[i]->stmt),
&this_align, &align_bitpos);
if (this_align > align)
{
align = this_align;
align_base = m_store_info[i]->bitpos - align_bitpos;
}
}
unsigned HOST_WIDE_INT align_bitpos
= (m_store_info[first]->bitpos - align_base) & (align - 1);
if (align_bitpos)
align = least_bit_hwi (align_bitpos);
if (align < try_size)
return false;
}
tree type;
switch (try_size)
{
case 16: type = uint16_type_node; break;
case 32: type = uint32_type_node; break;
case 64: type = uint64_type_node; break;
default: gcc_unreachable ();
}
struct symbolic_number n;
gimple *ins_stmt = NULL;
int vuse_store = -1;
unsigned int first_order = merged_store->first_order;
unsigned int last_order = merged_store->last_order;
gimple *first_stmt = merged_store->first_stmt;
gimple *last_stmt = merged_store->last_stmt;
unsigned HOST_WIDE_INT end = merged_store->start + merged_store->width;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
store_immediate_info *infof = m_store_info[first];
for (unsigned int i = first; i <= last; ++i)
{
store_immediate_info *info = m_store_info[i];
struct symbolic_number this_n = info->n;
this_n.type = type;
if (!this_n.base_addr)
this_n.range = try_size / BITS_PER_UNIT;
else
/* Update vuse in case it has changed by output_merged_stores. */
this_n.vuse = gimple_vuse (info->ins_stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
unsigned int bitpos = info->bitpos - infof->bitpos;
if (!do_shift_rotate (LSHIFT_EXPR, &this_n,
BYTES_BIG_ENDIAN
? try_size - info->bitsize - bitpos
: bitpos))
return false;
if (this_n.base_addr && vuse_store)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
unsigned int j;
for (j = first; j <= last; ++j)
if (this_n.vuse == gimple_vuse (m_store_info[j]->stmt))
break;
if (j > last)
{
if (vuse_store == 1)
return false;
vuse_store = 0;
}
}
if (i == first)
{
n = this_n;
ins_stmt = info->ins_stmt;
}
else
{
if (n.base_addr && n.vuse != this_n.vuse)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
if (vuse_store == 0)
return false;
vuse_store = 1;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
}
if (info->order > last_order)
{
last_order = info->order;
last_stmt = info->stmt;
}
else if (info->order < first_order)
{
first_order = info->order;
first_stmt = info->stmt;
}
end = MAX (end, info->bitpos + info->bitsize);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
ins_stmt = perform_symbolic_merge (ins_stmt, &n, info->ins_stmt,
bswap: Fix up symbolic merging for xor and plus [PR103376] On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote: > This patch implements PR tree-optimization/103345 to merge adjacent > loads when combined with addition or bitwise xor. The current code > in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior, > so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in > the same way at BIT_IOR_EXPR. Unfortunately they aren't exactly the same. They work the same if always at least one operand (or corresponding byte in it) is known to be 0, 0 | 0 = 0 ^ 0 = 0 + 0 = 0. But for | also x | x = x for any other x, so perform_symbolic_merge has been accepting either that at least one of the bytes is 0 or that both are the same, but that is wrong for ^ and +. The following patch fixes that by passing through the code of binary operation and allowing non-zero masked1 == masked2 through only for BIT_IOR_EXPR. Thinking more about it, perhaps we could do more for BIT_XOR_EXPR. We could allow masked1 == masked2 case for it, but would need to do something different than the n->n = n1->n | n2->n; we do on all the bytes together. In particular, for masked1 == masked2 if masked1 != 0 (well, for 0 both variants are the same) and masked1 != 0xff we would need to clear corresponding n->n byte instead of setting it to the input as x ^ x = 0 (but if we don't know what x and y are, the result is also don't know). Now, for plus it is much harder, because not only for non-zero operands we don't know what the result is, but it can modify upper bytes as well. So perhaps only if current's byte masked1 && masked2 set the resulting byte to 0xff (unknown) iff the byte above it is 0 and 0, and set that resulting byte to 0xff too. Also, even for | we could instead of return NULL just set the resulting byte to 0xff if it is different, perhaps it will be masked off later on. 2021-11-24 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/103376 * gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE argument. If CODE is not BIT_IOR_EXPR, ensure that one of masked1 or masked2 is 0. (find_bswap_or_nop_1, find_bswap_or_nop, imm_store_chain_info::try_coalesce_bswap): Adjust perform_symbolic_merge callers. * gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
&this_n, &n, BIT_IOR_EXPR);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (ins_stmt == NULL)
return false;
}
}
uint64_t cmpxchg, cmpnop;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bool cast64_to_32;
find_bswap_or_nop_finalize (&n, &cmpxchg, &cmpnop, &cast64_to_32);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* A complete byte swap should make the symbolic number to start with
the largest digit in the highest order byte. Unchanged symbolic
number indicates a read with same endianness as target architecture. */
if (n.n != cmpnop && n.n != cmpxchg)
return false;
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
/* For now. */
if (cast64_to_32)
return false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (n.base_addr == NULL_TREE && !is_gimple_val (n.src))
return false;
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
if (!check_no_overlap (m_store_info, last, false, first_order, last_order,
merged_store->start, end, first_earlier, first))
return false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* Don't handle memory copy this way if normal non-bswap processing
would handle it too. */
if (n.n == cmpnop && (unsigned) n.n_ops == last - first + 1)
{
unsigned int i;
for (i = first; i <= last; ++i)
if (m_store_info[i]->rhs_code != MEM_REF)
break;
if (i == last + 1)
return false;
}
if (n.n == cmpxchg)
switch (try_size)
{
case 16:
/* Will emit LROTATE_EXPR. */
break;
case 32:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing)
break;
return false;
case 64:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
&& optab_handler (bswap_optab, DImode) != CODE_FOR_nothing)
break;
return false;
default:
gcc_unreachable ();
}
if (!allow_unaligned && n.base_addr)
{
unsigned int align = get_object_alignment (n.src);
if (align < try_size)
return false;
}
/* If each load has vuse of the corresponding store, need to verify
the loads can be sunk right before the last store. */
if (vuse_store == 1)
{
auto_vec<tree, 64> refs;
for (unsigned int i = first; i <= last; ++i)
gather_bswap_load_refs (&refs,
gimple_assign_rhs1 (m_store_info[i]->stmt));
use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org> gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise.
2021-06-12 05:49:22 +02:00
for (tree ref : refs)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (stmts_may_clobber_ref_p (first_stmt, last_stmt, ref))
return false;
n.vuse = NULL_TREE;
}
infof->n = n;
infof->ins_stmt = ins_stmt;
for (unsigned int i = first; i <= last; ++i)
{
m_store_info[i]->rhs_code = n.n == cmpxchg ? LROTATE_EXPR : NOP_EXPR;
m_store_info[i]->ops[0].base_addr = NULL_TREE;
m_store_info[i]->ops[1].base_addr = NULL_TREE;
if (i != first)
merged_store->merge_into (m_store_info[i]);
}
return true;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Go through the candidate stores recorded in m_store_info and merge them
into merged_store_group objects recorded into m_merged_store_groups
representing the widened stores. Return true if coalescing was successful
and the number of widened stores is fewer than the original number
of stores. */
bool
imm_store_chain_info::coalesce_immediate_stores ()
{
/* Anything less can't be processed. */
if (m_store_info.length () < 2)
return false;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Attempting to coalesce %u stores in chain\n",
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
m_store_info.length ());
store_immediate_info *info;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
unsigned int i, ignore = 0;
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
unsigned int first_earlier = 0;
unsigned int end_earlier = 0;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Order the stores by the bitposition they write to. */
m_store_info.qsort (sort_by_bitpos);
info = m_store_info[0];
merged_store_group *merged_store = new merged_store_group (info);
if (dump_file && (dump_flags & TDF_DETAILS))
fputs ("New store group\n", dump_file);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
FOR_EACH_VEC_ELT (m_store_info, i, info)
{
unsigned HOST_WIDE_INT new_bitregion_start, new_bitregion_end;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (i <= ignore)
goto done;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
while (first_earlier < end_earlier
&& (m_store_info[first_earlier]->bitpos
+ m_store_info[first_earlier]->bitsize
<= merged_store->start))
first_earlier++;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
/* First try to handle group of stores like:
p[0] = data >> 24;
p[1] = data >> 16;
p[2] = data >> 8;
p[3] = data;
using the bswap framework. */
if (info->bitpos == merged_store->start + merged_store->width
&& merged_store->stores.length () == 1
&& merged_store->stores[0]->ins_stmt != NULL
&& info->lp_nr == merged_store->lp_nr
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
&& info->ins_stmt != NULL)
{
unsigned int try_size;
for (try_size = 64; try_size >= 16; try_size >>= 1)
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
if (try_coalesce_bswap (merged_store, i - 1, try_size,
first_earlier))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
break;
if (try_size >= 16)
{
ignore = i + merged_store->stores.length () - 1;
m_merged_store_groups.safe_push (merged_store);
if (ignore < m_store_info.length ())
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
{
merged_store = new merged_store_group (m_store_info[ignore]);
end_earlier = ignore;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else
merged_store = NULL;
goto done;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
}
}
new_bitregion_start
= MIN (merged_store->bitregion_start, info->bitregion_start);
new_bitregion_end
= MAX (merged_store->bitregion_end, info->bitregion_end);
if (info->order >= merged_store->first_nonmergeable_order
|| (((new_bitregion_end - new_bitregion_start + 1) / BITS_PER_UNIT)
Apply mechanical replacement (generated patch). 2019-11-12 Martin Liska <mliska@suse.cz> * asan.c (asan_sanitize_stack_p): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. (asan_sanitize_allocas_p): Likewise. (asan_emit_stack_protection): Likewise. (asan_protect_global): Likewise. (instrument_derefs): Likewise. (instrument_builtin_call): Likewise. (asan_expand_mark_ifn): Likewise. * auto-profile.c (auto_profile): Likewise. * bb-reorder.c (copy_bb_p): Likewise. (duplicate_computed_gotos): Likewise. * builtins.c (inline_expand_builtin_string_cmp): Likewise. * cfgcleanup.c (try_crossjump_to_edge): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.c (defer_stack_allocation): Likewise. (stack_protect_classify_type): Likewise. (pass_expand::execute): Likewise. * cfgloopanal.c (expected_loop_iterations_unbounded): Likewise. (estimate_reg_pressure_cost): Likewise. * cgraph.c (cgraph_edge::maybe_hot_p): Likewise. * combine.c (combine_instructions): Likewise. (record_value_for_reg): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_option_validate_param): Likewise. (aarch64_option_default_params): Likewise. * common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise. * common/config/sh/sh-common.c (sh_option_default_params): Likewise. * config/aarch64/aarch64.c (aarch64_output_probe_stack_range): Likewise. (aarch64_allocate_and_probe_stack_space): Likewise. (aarch64_expand_epilogue): Likewise. (aarch64_override_options_internal): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arm/arm.c (arm_option_override): Likewise. (arm_valid_target_attribute_p): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (get_probe_interval): Likewise. (ix86_adjust_stack_and_probe_stack_clash): Likewise. (ix86_max_noce_ifcvt_seq_cost): Likewise. * config/ia64/ia64.c (ia64_adjust_cost): Likewise. * config/rs6000/rs6000-logue.c (get_stack_clash_protection_probe_interval): Likewise. (get_stack_clash_protection_guard_size): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/s390/s390.c (allocate_stack_space): Likewise. (s390_emit_prologue): Likewise. (s390_option_override_internal): Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/visium/visium.c (visium_option_override): Likewise. * coverage.c (get_coverage_counts): Likewise. (coverage_compute_profile_id): Likewise. (coverage_begin_function): Likewise. (coverage_end_function): Likewise. * cse.c (cse_find_path): Likewise. (cse_extended_basic_block): Likewise. (cse_main): Likewise. * cselib.c (cselib_invalidate_mem): Likewise. * dse.c (dse_step1): Likewise. * emit-rtl.c (set_new_first_and_last_insn): Likewise. (get_max_insn_count): Likewise. (make_debug_insn_raw): Likewise. (init_emit): Likewise. * explow.c (compute_stack_clash_protection_loop_data): Likewise. * final.c (compute_alignments): Likewise. * fold-const.c (fold_range_test): Likewise. (fold_truth_andor): Likewise. (tree_single_nonnegative_warnv_p): Likewise. (integer_valued_real_single_p): Likewise. * gcse.c (want_to_gcse_p): Likewise. (prune_insertions_deletions): Likewise. (hoist_code): Likewise. (gcse_or_cprop_is_too_expensive): Likewise. * ggc-common.c: Likewise. * ggc-page.c (ggc_collect): Likewise. * gimple-loop-interchange.cc (MAX_NUM_STMT): Likewise. (MAX_DATAREFS): Likewise. (OUTER_STRIDE_RATIO): Likewise. * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise. * gimple-loop-versioning.cc (loop_versioning::max_insns_for_loop): Likewise. * gimple-ssa-split-paths.c (is_feasible_trace): Likewise. * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (imm_store_chain_info::output_merged_store): Likewise. (pass_store_merging::process_store): Likewise. * gimple-ssa-strength-reduction.c (find_basis_for_base_expr): Likewise. * graphite-isl-ast-to-gimple.c (class translate_isl_ast_to_gimple): Likewise. (scop_to_isl_ast): Likewise. * graphite-optimize-isl.c (get_schedule_for_node_st): Likewise. (optimize_isl): Likewise. * graphite-scop-detection.c (build_scops): Likewise. * haifa-sched.c (set_modulo_params): Likewise. (rank_for_schedule): Likewise. (model_add_to_worklist): Likewise. (model_promote_insn): Likewise. (model_choose_insn): Likewise. (queue_to_ready): Likewise. (autopref_multipass_dfa_lookahead_guard): Likewise. (schedule_block): Likewise. (sched_init): Likewise. * hsa-gen.c (init_prologue): Likewise. * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Likewise. (cond_move_process_if_block): Likewise. * ipa-cp.c (ipcp_lattice::add_value): Likewise. (merge_agg_lats_step): Likewise. (devirtualization_time_bonus): Likewise. (hint_time_bonus): Likewise. (incorporate_penalties): Likewise. (good_cloning_opportunity_p): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (decompose_param_expr): Likewise. (set_switch_stmt_execution_predicate): Likewise. (analyze_function_body): Likewise. (compute_fn_summary): Likewise. * ipa-inline-analysis.c (estimate_growth): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (inline_insns_single): Likewise. (inline_insns_auto): Likewise. (can_inline_edge_by_limits_p): Likewise. (want_early_inline_function_p): Likewise. (big_speedup_p): Likewise. (want_inline_small_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (edge_badness): Likewise. (recursive_inlining): Likewise. (compute_max_insns): Likewise. (early_inliner): Likewise. * ipa-polymorphic-call.c (csftc_abort_walking_p): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (determine_known_aggregate_parts): Likewise. (ipa_analyze_node): Likewise. (ipcp_transform_function): Likewise. * ipa-split.c (consider_split): Likewise. * ipa-sra.c (allocate_access): Likewise. (process_scan_results): Likewise. (ipa_sra_summarize_function): Likewise. (pull_accesses_from_callee): Likewise. * ira-build.c (loop_compare_func): Likewise. (mark_loops_for_removal): Likewise. * ira-conflicts.c (build_conflict_bit_table): Likewise. * loop-doloop.c (doloop_optimize): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. (move_loop_invariants): Likewise. * loop-unroll.c (decide_unroll_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. (expand_var_during_unrolling): Likewise. * lra-assigns.c (spill_for): Likewise. * lra-constraints.c (EBB_PROBABILITY_CUTOFF): Likewise. * modulo-sched.c (sms_schedule): Likewise. (DFA_HISTORY): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (common_handle_option): Likewise. * postreload-gcse.c (eliminate_partially_redundant_load): Likewise. (if): Likewise. * predict.c (get_hot_bb_threshold): Likewise. (maybe_hot_count_p): Likewise. (probably_never_executed): Likewise. (predictable_edge_p): Likewise. (predict_loops): Likewise. (expr_expected_value_1): Likewise. (tree_predict_by_opcode): Likewise. (handle_missing_profiles): Likewise. * reload.c (find_equiv_reg): Likewise. * reorg.c (redundant_insn): Likewise. * resource.c (mark_target_live_regs): Likewise. (incr_ticks_for_insn): Likewise. * sanopt.c (pass_sanopt::execute): Likewise. * sched-deps.c (sched_analyze_1): Likewise. (sched_analyze_2): Likewise. (sched_analyze_insn): Likewise. (deps_analyze_insn): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (find_single_block_region): Likewise. (too_large): Likewise. (haifa_find_rgns): Likewise. (extend_rgns): Likewise. (new_ready): Likewise. (schedule_region): Likewise. (sched_rgn_init): Likewise. * sel-sched-ir.c (make_region_from_loop): Likewise. * sel-sched-ir.h (MAX_WS): Likewise. * sel-sched.c (process_pipelined_exprs): Likewise. (sel_setup_region_sched_flags): Likewise. * shrink-wrap.c (try_shrink_wrapping): Likewise. * targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise. * toplev.c (print_version): Likewise. (process_options): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_log_add): Likewise. * tree-chrec.c (chrec_fold_plus_1): Likewise. * tree-data-ref.c (split_constant_offset): Likewise. (compute_all_dependences): Likewise. * tree-if-conv.c (MAX_PHI_ARG_NUM): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. * tree-loop-distribution.c (MAX_DATAREFS_NUM): Likewise. * tree-parloops.c (MIN_PER_THREAD): Likewise. (create_parallel_loop): Likewise. * tree-predcom.c (determine_unroll_factor): Likewise. * tree-scalar-evolution.c (instantiate_scev_r): Likewise. * tree-sra.c (analyze_all_variable_accesses): Likewise. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Likewise. * tree-ssa-dse.c (setup_live_bytes_from_ref): Likewise. (dse_optimize_redundant_stores): Likewise. (dse_classify_store): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise. * tree-ssa-loop-im.c (LIM_EXPENSIVE): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise. (CONSIDER_ALL_CANDIDATES_BOUND): Likewise. (MAX_CONSIDERED_GROUPS): Likewise. (ALWAYS_PRUNE_CAND_SET_BOUND): Likewise. * tree-ssa-loop-manip.c (can_unroll_loop_p): Likewise. * tree-ssa-loop-niter.c (MAX_ITERATIONS_TO_TRACK): Likewise. * tree-ssa-loop-prefetch.c (PREFETCH_BLOCK): Likewise. (L1_CACHE_SIZE_BYTES): Likewise. (L2_CACHE_SIZE_BYTES): Likewise. (should_issue_prefetch_p): Likewise. (schedule_prefetches): Likewise. (determine_unroll_factor): Likewise. (volume_of_references): Likewise. (add_subscript_strides): Likewise. (self_reuse_distance): Likewise. (mem_ref_count_reasonable_p): Likewise. (insn_to_prefetch_ratio_too_small_p): Likewise. (loop_prefetch_arrays): Likewise. (tree_ssa_prefetch_arrays): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. (convert_mult_to_fma): Likewise. (math_opts_dom_walker::after_dom_children): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. (hoist_adjacent_loads): Likewise. (gate_hoist_loads): Likewise. * tree-ssa-pre.c (translate_vuse_through_block): Likewise. (compute_partial_antic_aux): Likewise. * tree-ssa-reassoc.c (get_reassociation_width): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. (do_rpo_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. * tree-ssa-sink.c (select_best_block): Likewise. * tree-ssa-strlen.c (new_stridx): Likewise. (new_addr_stridx): Likewise. (get_range_strlen_dynamic): Likewise. (class ssa_name_limit_t): Likewise. * tree-ssa-structalias.c (push_fields_onto_fieldstack): Likewise. (create_variable_info_for_1): Likewise. (init_alias_vars): Likewise. * tree-ssa-tail-merge.c (find_clusters_1): Likewise. (tail_merge_optimize): Likewise. * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Likewise. (thread_jumps::fsm_find_control_statement_thread_paths): Likewise. (thread_jumps::find_jump_threads_backwards): Likewise. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Likewise. * tree-ssa-uninit.c (compute_control_dep_chain): Likewise. * tree-switch-conversion.c (switch_conversion::check_range): Likewise. (jump_table_cluster::can_be_handled): Likewise. * tree-switch-conversion.h (jump_table_cluster::case_values_threshold): Likewise. (SWITCH_CONVERSION_BRANCH_RATIO): Likewise. (param_switch_conversion_branch_ratio): Likewise. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_analyze_loop_costing): Likewise. (vect_get_datarefs_in_loop): Likewise. (vect_analyze_loop): Likewise. * tree-vect-slp.c (vect_slp_bb): Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (vrp_prop::check_mem_ref): Likewise. * tree.c (wide_int_to_tree_1): Likewise. (cache_integer_cst): Likewise. * var-tracking.c (EXPR_USE_DEPTH): Likewise. (reverse_op): Likewise. (vt_find_locations): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_parse_gimple_body): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_hints::namespace_hints): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * typeck.c (comptypes): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-partition.c (lto_balanced_map): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * lto.c (do_whole_program_analysis): Likewise. From-SVN: r278085
2019-11-12 11:08:40 +01:00
> (unsigned) param_store_merging_max_size))
;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* |---store 1---|
|---store 2---|
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
Overlapping stores. */
else if (IN_RANGE (info->bitpos, merged_store->start,
store-merging: Fix coalesce_immediate_stores [PR93820] The following testcase is miscompiled in 8+. The problem is that check_no_overlap has a special case for INTEGER_CST marked stores (i.e. stores of constants), if both all currenly merged stores and the one under consideration for merging with them are marked that way, it anticipates that other INTEGER_CST marked stores that overlap with those and precede those (have smaller info->order) could be merged with those and doesn't punt for them. In PR86844 and PR87859 fixes I've then added quite large code that is performed after check_no_overlap and tries to find out if we need and can merge further INTEGER_CST marked stores, or need to punt. Unfortunately, that code is there only in the overlapping case code and the testcase below shows that we really need it even in the adjacent store case. After sort_by_bitpos we have: bitpos width order rhs_code 96 32 3 INTEGER_CST 128 32 1 INTEGER_CST 128 128 2 INTEGER_CST 192 32 0 MEM_REF Because of the missing PR86844/PR87859-ish code in the adjacent store case, we merge the adjacent (memory wise) stores 96/32/3 and 128/32/1, and then we consider the 128-bit store which is in program-order in between them, but in this case we punt, because the merging would extend the merged store region from bitpos 96 and 64-bits to bitpos 96 and 160-bits and that has an overlap with an incompatible store (the MEM_REF one). The problem is that we can't really punt this way, because the 128-bit store is in between those two we've merged already, so either we manage to merge even that one together with the others, or would need to avoid already merging the 96/32/3 and 128/32/1 stores together. Now, rather than copying around the PR86844/PR87859 code to the other spot, we can actually just use the overlapping code, merge_overlapping is really a superset of merge_into, so that is what the patch does. If doing adjacent store merge for rhs_code other than INTEGER_CST, I believe the current code is already fine, check_no_overlap in that case doesn't make the exception and will punt if there is some earlier (smaller order) non-mergeable overlapping store. There is just one case that could be problematic, if the merged_store has BIT_INSERT_EXPRs in them and the new store is a constant store (INTEGER_CST rhs_code), then check_no_overlap would do the exception and still would allow the special case. But we really shouldn't have the special case in that case, so this patch also changes check_no_overlap to just have a bool whether we should have the special case or not. Note, as I said in the PR, for GCC11 we could consider performing some kind of cheap DSE during the store merging (perhaps guarded with flag_tree_dse). And another thing to consider is only consider as problematic non-mergeable stores that not only have order smaller than last_order as currently, but also have order larger than first_order, as in this testcase if we actually ignored (not merged with anything at all) the 192/32/0 store, because it is not in between the other stores we'd merge, it would be fine to merge the other 3 stores, though of course the testcase can be easily adjusted by putting the 192/32 store after the 128/32 store and then this patch would be still needed. Though, I think I'd need more time thinking this over. 2020-02-26 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93820 * gimple-ssa-store-merging.c (check_no_overlap): Change RHS_CODE argument to ALL_INTEGER_CST_P boolean. (imm_store_chain_info::try_coalesce_bswap): Adjust caller. (imm_store_chain_info::coalesce_immediate_stores): Likewise. Handle adjacent INTEGER_CST store into merged_store->only_constants like overlapping one. * gcc.dg/pr93820.c: New test.
2020-02-26 09:33:48 +01:00
merged_store->start + merged_store->width - 1)
/* |---store 1---||---store 2---|
Handle also the consecutive INTEGER_CST stores case here,
as we have here the code to deal with overlaps. */
|| (info->bitregion_start <= merged_store->bitregion_end
&& info->rhs_code == INTEGER_CST
&& merged_store->only_constants
&& merged_store->can_be_merged_into (info)))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Only allow overlapping stores of constants. */
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (info->rhs_code == INTEGER_CST
&& merged_store->only_constants
&& info->lp_nr == merged_store->lp_nr)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
unsigned int first_order
= MIN (merged_store->first_order, info->order);
unsigned int last_order
= MAX (merged_store->last_order, info->order);
unsigned HOST_WIDE_INT end
= MAX (merged_store->start + merged_store->width,
info->bitpos + info->bitsize);
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
if (check_no_overlap (m_store_info, i, true, first_order,
last_order, merged_store->start, end,
first_earlier, end_earlier))
{
/* check_no_overlap call above made sure there are no
overlapping stores with non-INTEGER_CST rhs_code
in between the first and last of the stores we've
just merged. If there are any INTEGER_CST rhs_code
stores in between, we need to merge_overlapping them
even if in the sort_by_bitpos order there are other
overlapping stores in between. Keep those stores as is.
Example:
MEM[(int *)p_28] = 0;
MEM[(char *)p_28 + 3B] = 1;
MEM[(char *)p_28 + 1B] = 2;
MEM[(char *)p_28 + 2B] = MEM[(char *)p_28 + 6B];
We can't merge the zero store with the store of two and
not merge anything else, because the store of one is
in the original order in between those two, but in
store_by_bitpos order it comes after the last store that
we can't merge with them. We can merge the first 3 stores
and keep the last store as is though. */
unsigned int len = m_store_info.length ();
unsigned int try_order = last_order;
unsigned int first_nonmergeable_order;
unsigned int k;
bool last_iter = false;
int attempts = 0;
do
{
unsigned int max_order = 0;
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
unsigned int min_order = first_order;
unsigned first_nonmergeable_int_order = ~0U;
unsigned HOST_WIDE_INT this_end = end;
k = i;
first_nonmergeable_order = ~0U;
for (unsigned int j = i + 1; j < len; ++j)
{
store_immediate_info *info2 = m_store_info[j];
if (info2->bitpos >= this_end)
break;
if (info2->order < try_order)
{
if (info2->rhs_code != INTEGER_CST
|| info2->lp_nr != merged_store->lp_nr)
{
/* Normally check_no_overlap makes sure this
doesn't happen, but if end grows below,
then we need to process more stores than
check_no_overlap verified. Example:
MEM[(int *)p_5] = 0;
MEM[(short *)p_5 + 3B] = 1;
MEM[(char *)p_5 + 4B] = _9;
MEM[(char *)p_5 + 2B] = 2; */
k = 0;
break;
}
k = j;
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
min_order = MIN (min_order, info2->order);
this_end = MAX (this_end,
info2->bitpos + info2->bitsize);
}
else if (info2->rhs_code == INTEGER_CST
&& info2->lp_nr == merged_store->lp_nr
&& !last_iter)
{
max_order = MAX (max_order, info2->order + 1);
first_nonmergeable_int_order
= MIN (first_nonmergeable_int_order,
info2->order);
}
else
first_nonmergeable_order
= MIN (first_nonmergeable_order, info2->order);
}
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
if (k > i
&& !check_no_overlap (m_store_info, len - 1, true,
min_order, try_order,
merged_store->start, this_end,
first_earlier, end_earlier))
k = 0;
if (k == 0)
{
if (last_order == try_order)
break;
/* If this failed, but only because we grew
try_order, retry with the last working one,
so that we merge at least something. */
try_order = last_order;
last_iter = true;
continue;
}
last_order = try_order;
/* Retry with a larger try_order to see if we could
merge some further INTEGER_CST stores. */
if (max_order
&& (first_nonmergeable_int_order
< first_nonmergeable_order))
{
try_order = MIN (max_order,
first_nonmergeable_order);
try_order
= MIN (try_order,
merged_store->first_nonmergeable_order);
if (try_order > last_order && ++attempts < 16)
continue;
}
first_nonmergeable_order
= MIN (first_nonmergeable_order,
first_nonmergeable_int_order);
end = this_end;
break;
}
while (1);
if (k != 0)
{
merged_store->merge_overlapping (info);
merged_store->first_nonmergeable_order
= MIN (merged_store->first_nonmergeable_order,
first_nonmergeable_order);
for (unsigned int j = i + 1; j <= k; j++)
{
store_immediate_info *info2 = m_store_info[j];
gcc_assert (info2->bitpos < end);
if (info2->order < last_order)
{
gcc_assert (info2->rhs_code == INTEGER_CST);
if (info != info2)
merged_store->merge_overlapping (info2);
}
/* Other stores are kept and not merged in any
way. */
}
ignore = k;
goto done;
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* |---store 1---||---store 2---|
This store is consecutive to the previous one.
Merge it into the current store group. There can be gaps in between
the stores, but there can't be gaps in between bitregions. */
else if (info->bitregion_start <= merged_store->bitregion_end
&& merged_store->can_be_merged_into (info))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_immediate_info *infof = merged_store->stores[0];
/* All the rhs_code ops that take 2 operands are commutative,
swap the operands if it could make the operands compatible. */
if (infof->ops[0].base_addr
&& infof->ops[1].base_addr
&& info->ops[0].base_addr
&& info->ops[1].base_addr
&& known_eq (info->ops[1].bitpos - infof->ops[0].bitpos,
info->bitpos - infof->bitpos)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
&& operand_equal_p (info->ops[1].base_addr,
infof->ops[0].base_addr, 0))
{
std::swap (info->ops[0], info->ops[1]);
info->ops_swapped_p = true;
}
store-merging: Fix coalesce_immediate_stores [PR93820] The following testcase is miscompiled in 8+. The problem is that check_no_overlap has a special case for INTEGER_CST marked stores (i.e. stores of constants), if both all currenly merged stores and the one under consideration for merging with them are marked that way, it anticipates that other INTEGER_CST marked stores that overlap with those and precede those (have smaller info->order) could be merged with those and doesn't punt for them. In PR86844 and PR87859 fixes I've then added quite large code that is performed after check_no_overlap and tries to find out if we need and can merge further INTEGER_CST marked stores, or need to punt. Unfortunately, that code is there only in the overlapping case code and the testcase below shows that we really need it even in the adjacent store case. After sort_by_bitpos we have: bitpos width order rhs_code 96 32 3 INTEGER_CST 128 32 1 INTEGER_CST 128 128 2 INTEGER_CST 192 32 0 MEM_REF Because of the missing PR86844/PR87859-ish code in the adjacent store case, we merge the adjacent (memory wise) stores 96/32/3 and 128/32/1, and then we consider the 128-bit store which is in program-order in between them, but in this case we punt, because the merging would extend the merged store region from bitpos 96 and 64-bits to bitpos 96 and 160-bits and that has an overlap with an incompatible store (the MEM_REF one). The problem is that we can't really punt this way, because the 128-bit store is in between those two we've merged already, so either we manage to merge even that one together with the others, or would need to avoid already merging the 96/32/3 and 128/32/1 stores together. Now, rather than copying around the PR86844/PR87859 code to the other spot, we can actually just use the overlapping code, merge_overlapping is really a superset of merge_into, so that is what the patch does. If doing adjacent store merge for rhs_code other than INTEGER_CST, I believe the current code is already fine, check_no_overlap in that case doesn't make the exception and will punt if there is some earlier (smaller order) non-mergeable overlapping store. There is just one case that could be problematic, if the merged_store has BIT_INSERT_EXPRs in them and the new store is a constant store (INTEGER_CST rhs_code), then check_no_overlap would do the exception and still would allow the special case. But we really shouldn't have the special case in that case, so this patch also changes check_no_overlap to just have a bool whether we should have the special case or not. Note, as I said in the PR, for GCC11 we could consider performing some kind of cheap DSE during the store merging (perhaps guarded with flag_tree_dse). And another thing to consider is only consider as problematic non-mergeable stores that not only have order smaller than last_order as currently, but also have order larger than first_order, as in this testcase if we actually ignored (not merged with anything at all) the 192/32/0 store, because it is not in between the other stores we'd merge, it would be fine to merge the other 3 stores, though of course the testcase can be easily adjusted by putting the 192/32 store after the 128/32 store and then this patch would be still needed. Though, I think I'd need more time thinking this over. 2020-02-26 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93820 * gimple-ssa-store-merging.c (check_no_overlap): Change RHS_CODE argument to ALL_INTEGER_CST_P boolean. (imm_store_chain_info::try_coalesce_bswap): Adjust caller. (imm_store_chain_info::coalesce_immediate_stores): Likewise. Handle adjacent INTEGER_CST store into merged_store->only_constants like overlapping one. * gcc.dg/pr93820.c: New test.
2020-02-26 09:33:48 +01:00
if (check_no_overlap (m_store_info, i, false,
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
MIN (merged_store->first_order, info->order),
MAX (merged_store->last_order, info->order),
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
merged_store->start,
MAX (merged_store->start + merged_store->width,
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
info->bitpos + info->bitsize),
first_earlier, end_earlier))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
/* Turn MEM_REF into BIT_INSERT_EXPR for bit-field stores. */
if (info->rhs_code == MEM_REF && infof->rhs_code != MEM_REF)
{
info->rhs_code = BIT_INSERT_EXPR;
info->ops[0].val = gimple_assign_rhs1 (info->stmt);
info->ops[0].base_addr = NULL_TREE;
}
else if (infof->rhs_code == MEM_REF && info->rhs_code != MEM_REF)
{
use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org> gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise.
2021-06-12 05:49:22 +02:00
for (store_immediate_info *infoj : merged_store->stores)
{
infoj->rhs_code = BIT_INSERT_EXPR;
infoj->ops[0].val = gimple_assign_rhs1 (infoj->stmt);
infoj->ops[0].base_addr = NULL_TREE;
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
merged_store->bit_insertion = true;
}
if ((infof->ops[0].base_addr
? compatible_load_p (merged_store, info, base_addr, 0)
: !info->ops[0].base_addr)
&& (infof->ops[1].base_addr
? compatible_load_p (merged_store, info, base_addr, 1)
: !info->ops[1].base_addr))
{
merged_store->merge_into (info);
goto done;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* |---store 1---| <gap> |---store 2---|.
Gap between stores or the rhs not compatible. Start a new group. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Try to apply all the stores recorded for the group to determine
the bitpattern they write and discard it if that fails.
This will also reject single-store groups. */
if (merged_store->apply_stores ())
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
m_merged_store_groups.safe_push (merged_store);
else
delete merged_store;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
merged_store = new merged_store_group (info);
store-merging: Consider also overlapping stores earlier in the by bitpos sorting [PR97053] As the testcases show, if we have something like: MEM <char[12]> [&b + 8B] = {}; MEM[(short *) &b] = 5; _5 = *x_4(D); MEM <long long unsigned int> [&b + 2B] = _5; MEM[(char *)&b + 16B] = 88; MEM[(int *)&b + 20B] = 1; then in sort_by_bitpos the stores are almost like in the given order, except the first store is after the = _5; store. We can't coalesce the = 5; store with = _5;, because the latter is MEM_REF, while the former INTEGER_CST, and we can't coalesce the = _5 store with the = {} store because the former is MEM_REF, the latter INTEGER_CST. But we happily coalesce the remaining 3 stores, which is wrong, because the = _5; store overlaps those and is in between them in the program order. We already have code to deal with similar cases in check_no_overlap, but we deal only with the following stores in sort_by_bitpos order, not the earlier ones. The following patch checks also the earlier ones. In coalesce_immediate_stores it computes the first one that needs to be checked (all the ones whose bitpos + bitsize is smaller or equal to merged_store->start don't need to be checked and don't need to be checked even for any following attempts because of the sort_by_bitpos sorting) and the end of that (that is the first store in the merged_store). 2020-09-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97053 * gimple-ssa-store-merging.c (check_no_overlap): Add FIRST_ORDER, START, FIRST_EARLIER and LAST_EARLIER arguments. Return false if any stores between FIRST_EARLIER inclusive and LAST_EARLIER exclusive has order in between FIRST_ORDER and LAST_ORDER and overlaps the to be merged store. (imm_store_chain_info::try_coalesce_bswap): Add FIRST_EARLIER argument. Adjust check_no_overlap caller. (imm_store_chain_info::coalesce_immediate_stores): Add first_earlier and last_earlier variables, adjust them during iterations. Adjust check_no_overlap callers, call check_no_overlap even when extending overlapping stores by extra INTEGER_CST stores. * gcc.dg/store_merging_31.c: New test. * gcc.dg/store_merging_32.c: New test.
2020-09-16 09:42:33 +02:00
end_earlier = i;
if (dump_file && (dump_flags & TDF_DETAILS))
fputs ("New store group\n", dump_file);
done:
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Store %u:\nbitsize:" HOST_WIDE_INT_PRINT_DEC
" bitpos:" HOST_WIDE_INT_PRINT_DEC " val:",
i, info->bitsize, info->bitpos);
print_generic_expr (dump_file, gimple_assign_rhs1 (info->stmt));
fputc ('\n', dump_file);
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Record or discard the last store group. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (merged_store)
{
if (merged_store->apply_stores ())
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
m_merged_store_groups.safe_push (merged_store);
else
delete merged_store;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gcc_assert (m_merged_store_groups.length () <= m_store_info.length ());
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
bool success
= !m_merged_store_groups.is_empty ()
&& m_merged_store_groups.length () < m_store_info.length ();
if (success && dump_file)
fprintf (dump_file, "Coalescing successful!\nMerged into %u stores\n",
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
m_merged_store_groups.length ());
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return success;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Return the type to use for the merged stores or loads described by STMTS.
This is needed to get the alias sets right. If IS_LOAD, look for rhs,
otherwise lhs. Additionally set *CLIQUEP and *BASEP to MR_DEPENDENCE_*
of the MEM_REFs if any. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
static tree
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
get_alias_type_for_stmts (vec<gimple *> &stmts, bool is_load,
unsigned short *cliquep, unsigned short *basep)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
gimple *stmt;
unsigned int i;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree type = NULL_TREE;
tree ret = NULL_TREE;
*cliquep = 0;
*basep = 0;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
FOR_EACH_VEC_ELT (stmts, i, stmt)
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree ref = is_load ? gimple_assign_rhs1 (stmt)
: gimple_assign_lhs (stmt);
tree type1 = reference_alias_ptr_type (ref);
tree base = get_base_address (ref);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (i == 0)
{
if (TREE_CODE (base) == MEM_REF)
{
*cliquep = MR_DEPENDENCE_CLIQUE (base);
*basep = MR_DEPENDENCE_BASE (base);
}
ret = type = type1;
continue;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (!alias_ptr_types_compatible_p (type, type1))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
ret = ptr_type_node;
if (TREE_CODE (base) != MEM_REF
|| *cliquep != MR_DEPENDENCE_CLIQUE (base)
|| *basep != MR_DEPENDENCE_BASE (base))
{
*cliquep = 0;
*basep = 0;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return ret;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Return the location_t information we can find among the statements
in STMTS. */
static location_t
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
get_location_for_stmts (vec<gimple *> &stmts)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org> gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise.
2021-06-12 05:49:22 +02:00
for (gimple *stmt : stmts)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (gimple_has_location (stmt))
return gimple_location (stmt);
return UNKNOWN_LOCATION;
}
/* Used to decribe a store resulting from splitting a wide store in smaller
regularly-sized stores in split_group. */
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
class split_store
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * gimple-parser.c: Same. gcc/c-family/ChangeLog: PR c++/61339 * c-format.c (check_argument_type): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * constexpr.c (cxx_eval_call_expression): Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * constraint.cc (get_concept_definition): Same. * cp-tree.h: Same. * cxx-pretty-print.h: Same. * error.c: Same. * logic.cc (term_list::replace): Same. * name-lookup.c (find_local_binding): Same. * pt.c (tsubst_binary_right_fold): Same. * search.c (field_accessor_p): Same. * semantics.c (expand_or_defer_fn): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-dump.c: Change class-key from classi to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. gcc/ChangeLog: PR c++/61339 * align.h: Change class-key from class to struct and vice versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod. * alloc-pool.h: Same. * asan.c (shadow_mem_size): Same. * auto-profile.c: Same. * basic-block.h: Same. * bitmap.h: Same. * cfgexpand.c (set_rtl): Same. (expand_one_stack_var_at): Same. * cfghooks.h: Same. * cfgloop.h: Same. * cgraph.h: Same. * config/i386/i386.h: Same. * df-problems.c (df_print_bb_index): Same. * df-scan.c: Same. * df.h (df_single_use): Same. * diagnostic-show-locus.c (layout::print_annotation_line): Same. (layout::annotation_line_showed_range_p): Same. (get_printed_columns): Same. (correction::ensure_terminated): Same. (line_corrections::~line_corrections): Same. * dojump.h: Same. * dse.c: Same. * dump-context.h: Same. * dumpfile.h: Same. * dwarf2out.c: Same. * edit-context.c: Same. * fibonacci_heap.c (test_union_of_equal_heaps): Same. * flags.h: Same. * function.c (assign_stack_local): Same. * function.h: Same. * gcc.c: Same. * gcov.c (block_info::block_info): Same. * genattrtab.c: Same. * genextract.c: Same. * genmatch.c (comparison_code_p): Same. (id_base::id_base): Same. (decision_tree::print): Same. * genoutput.c: Same. * genpreds.c (write_one_predicate_function): Same. * genrecog.c (validate_pattern): Same. (find_operand_positions): Same. (optimize_subroutine_group): Same. (merge_pattern_transition::merge_pattern_transition): Same. (merge_pattern_info::merge_pattern_info): Same. (merge_state_result::merge_state_result): Same. (merge_into_state): Same. * gensupport.c: Same. * gensupport.h: Same. * ggc-common.c (init_ggc_heuristics): Same. * ggc-tests.c (test_union): Same. * gimple-loop-interchange.cc (dump_induction): Same. * gimple-loop-versioning.cc: Same. * gimple-match.h (gimple_match_cond::any_else): Same. * gimple-ssa-backprop.c: Same. * gimple-ssa-sprintf.c: Same. * gimple-ssa-store-merging.c (store_operand_info::store_operand_info): Same. (store_immediate_info::store_immediate_info): Same. (merged_store_group::apply_stores): Same. (get_location_for_stmts): Same. * gimple-ssa-strength-reduction.c: Same. * gimple-ssa-warn-alloca.c: Same. * gimple-ssa-warn-restrict.c (pass_wrestrict::execute): Same. * godump.c (go_type_decl): Same. * hash-map-tests.c (test_map_of_strings_to_int): Same. * hash-map.h: Same. * hash-set-tests.c (test_set_of_strings): Same. * hsa-brig.c: Same. * hsa-common.h: Same. * hsa-gen.c (transformable_switch_to_sbr_p): Same. * input.c (assert_loceq): Same. * input.h: Same. * ipa-cp.c: Same. * ipa-devirt.c (possible_polymorphic_call_targets_1): Same. * ipa-fnsummary.h: Same. * ipa-inline.h: Same. * ipa-prop.h: Same. * ipa-split.c (visit_bb): Same. * ira-int.h (minmax_set_iter_next): Same. * loop-invariant.c: Same. * loop-iv.c: Same. * lra-eliminations.c: Same. * lra-int.h: Same. * lra-lives.c (mark_regno_dead): Same. * lra-remat.c: Same. * lra-spills.c: Same. * lto-streamer.h: Same. * mem-stats.h: Same. * omp-grid.c (omp_grid_lastprivate_predicate): Same. * omp-low.c (omp_clause_aligned_alignment): Same. * optabs-query.h (get_vcond_eq_icode): Same. * optabs.h: Same. * opts.c (wrap_help): Same. * poly-int.h: Same. * predict.c (predict_paths_leading_to_edge): Same. * pretty-print.h: Same. * profile-count.h: Same. * read-md.h: Same. * read-rtl-function.c: Same. * ree.c: Same. * reginfo.c: Same. * regrename.c: Same. * regrename.h: Same. * reload.h: Same. * rtl-iter.h: Same. * rtl.h (costs_add_n_insns): Same. * sanopt.c: Same. * sched-int.h: Same. * sel-sched-ir.h: Same. * selftest.h: Same. * sese.h (vec_find): Same. * stmt.c: Same. * target-globals.h: Same. * tree-affine.c (aff_combination_find_elt): Same. * tree-affine.h: Same. * tree-data-ref.h: Same. * tree-outof-ssa.c (ssa_is_replaceable_p): Same. * tree-predcom.c: Same. * tree-scalar-evolution.c (find_var_scev_info): Same. * tree-ssa-alias.h: Same. * tree-ssa-ccp.c: Same. * tree-ssa-coalesce.c (ssa_conflicts_dump): Same. * tree-ssa-loop-im.c (for_all_locs_in_loop): Same. (rewrite_mem_refs): Same. (execute_sm_if_changed): Same. (hoist_memory_references): Same. * tree-ssa-loop-ivopts.c (operator<=): Same. * tree-ssa-loop.h: Same. * tree-ssa-pre.c (get_or_alloc_expr_for_name): Same. * tree-ssa-structalias.c: Same. * tree-switch-conversion.h (cluster::cluster): Same. (simple_cluster::simple_cluster): Same. * tree-vect-patterns.c (type_conversion_p): Same. * tree-vectorizer.c (dump_stmt_cost): Same. * tree-vectorizer.h (loop_vec_info_for_loop): Same. * tree.c (protected_set_expr_location): Same. * tree.h (desired_pro_or_demotion_p): Same. (fndecl_built_in_p): Same. * unique-ptr-tests.cc: Same. * var-tracking.c (delete_variable_part): Same. * varasm.c (assemble_real): Same. (tree_output_constant_def): Same. * vec.c: Same. * wide-int-bitmask.h: Same. * wide-int.h (decompose): Same. From-SVN: r273308
2019-07-09 18:36:00 +02:00
public:
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT bytepos;
unsigned HOST_WIDE_INT size;
unsigned HOST_WIDE_INT align;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
auto_vec<store_immediate_info *> orig_stores;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* True if there is a single orig stmt covering the whole split store. */
bool orig;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
split_store (unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT);
};
/* Simple constructor. */
split_store::split_store (unsigned HOST_WIDE_INT bp,
unsigned HOST_WIDE_INT sz,
unsigned HOST_WIDE_INT al)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
: bytepos (bp), size (sz), align (al), orig (false)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
orig_stores.create (0);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Record all stores in GROUP that write to the region starting at BITPOS and
is of size BITSIZE. Record infos for such statements in STORES if
non-NULL. The stores in GROUP must be sorted by bitposition. Return INFO
if there is exactly one original store in the range (in that case ignore
clobber stmts, unless there are only clobber stmts). */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
static store_immediate_info *
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
find_constituent_stores (class merged_store_group *group,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
vec<store_immediate_info *> *stores,
unsigned int *first,
unsigned HOST_WIDE_INT bitpos,
unsigned HOST_WIDE_INT bitsize)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
store_immediate_info *info, *ret = NULL;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned int i;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
bool second = false;
bool update_first = true;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT end = bitpos + bitsize;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
for (i = *first; group->stores.iterate (i, &info); ++i)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
unsigned HOST_WIDE_INT stmt_start = info->bitpos;
unsigned HOST_WIDE_INT stmt_end = stmt_start + info->bitsize;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (stmt_end <= bitpos)
{
/* BITPOS passed to this function never decreases from within the
same split_group call, so optimize and don't scan info records
which are known to end before or at BITPOS next time.
Only do it if all stores before this one also pass this. */
if (update_first)
*first = i + 1;
continue;
}
else
update_first = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* The stores in GROUP are ordered by bitposition so if we're past
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
the region for this group return early. */
if (stmt_start >= end)
return ret;
if (gimple_clobber_p (info->stmt))
{
if (stores)
stores->safe_push (info);
if (ret == NULL)
ret = info;
continue;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (stores)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
stores->safe_push (info);
if (ret && !gimple_clobber_p (ret->stmt))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
ret = NULL;
second = true;
}
}
else if (ret && !gimple_clobber_p (ret->stmt))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
return NULL;
if (!second)
ret = info;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
return ret;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Return how many SSA_NAMEs used to compute value to store in the INFO
store have multiple uses. If any SSA_NAME has multiple uses, also
count statements needed to compute it. */
static unsigned
count_multiple_uses (store_immediate_info *info)
{
gimple *stmt = info->stmt;
unsigned ret = 0;
switch (info->rhs_code)
{
case INTEGER_CST:
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
case STRING_CST:
return 0;
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
if (info->bit_not_p)
{
if (!has_single_use (gimple_assign_rhs1 (stmt)))
ret = 1; /* Fall through below to return
the BIT_NOT_EXPR stmt and then
BIT_{AND,IOR,XOR}_EXPR and anything it
uses. */
else
/* stmt is after this the BIT_NOT_EXPR. */
stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
}
if (!has_single_use (gimple_assign_rhs1 (stmt)))
{
ret += 1 + info->ops[0].bit_not_p;
if (info->ops[1].base_addr)
ret += 1 + info->ops[1].bit_not_p;
return ret + 1;
}
stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
/* stmt is now the BIT_*_EXPR. */
if (!has_single_use (gimple_assign_rhs1 (stmt)))
ret += 1 + info->ops[info->ops_swapped_p].bit_not_p;
else if (info->ops[info->ops_swapped_p].bit_not_p)
{
gimple *stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
if (!has_single_use (gimple_assign_rhs1 (stmt2)))
++ret;
}
if (info->ops[1].base_addr == NULL_TREE)
{
gcc_checking_assert (!info->ops_swapped_p);
return ret;
}
if (!has_single_use (gimple_assign_rhs2 (stmt)))
ret += 1 + info->ops[1 - info->ops_swapped_p].bit_not_p;
else if (info->ops[1 - info->ops_swapped_p].bit_not_p)
{
gimple *stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt));
if (!has_single_use (gimple_assign_rhs1 (stmt2)))
++ret;
}
return ret;
case MEM_REF:
if (!has_single_use (gimple_assign_rhs1 (stmt)))
return 1 + info->ops[0].bit_not_p;
else if (info->ops[0].bit_not_p)
{
stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
if (!has_single_use (gimple_assign_rhs1 (stmt)))
return 1;
}
return 0;
case BIT_INSERT_EXPR:
return has_single_use (gimple_assign_rhs1 (stmt)) ? 0 : 1;
default:
gcc_unreachable ();
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Split a merged store described by GROUP by populating the SPLIT_STORES
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
vector (if non-NULL) with split_store structs describing the byte offset
(from the base), the bit size and alignment of each store as well as the
original statements involved in each such split group.
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
This is to separate the splitting strategy from the statement
building/emission/linking done in output_merged_store.
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
Return number of new stores.
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
If ALLOW_UNALIGNED_STORE is false, then all stores must be aligned.
If ALLOW_UNALIGNED_LOAD is false, then all loads must be aligned.
BZERO_FIRST may be true only when the first store covers the whole group
and clears it; if BZERO_FIRST is true, keep that first store in the set
unmodified and emit further stores for the overrides only.
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
If SPLIT_STORES is NULL, it is just a dry run to count number of
new stores. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
static unsigned int
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
split_group (merged_store_group *group, bool allow_unaligned_store,
bool allow_unaligned_load, bool bzero_first,
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
vec<split_store *> *split_stores,
unsigned *total_orig,
unsigned *total_new)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT pos = group->bitregion_start;
unsigned HOST_WIDE_INT size = group->bitregion_end - pos;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT bytepos = pos / BITS_PER_UNIT;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned HOST_WIDE_INT group_align = group->align;
unsigned HOST_WIDE_INT align_base = group->align_base;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
unsigned HOST_WIDE_INT group_load_align = group_align;
bool any_orig = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gcc_assert ((size % BITS_PER_UNIT == 0) && (pos % BITS_PER_UNIT == 0));
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
/* For bswap framework using sets of stores, all the checking has been done
earlier in try_coalesce_bswap and the result always needs to be emitted
as a single store. Likewise for string concatenation, */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (group->stores[0]->rhs_code == LROTATE_EXPR
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
|| group->stores[0]->rhs_code == NOP_EXPR
|| group->string_concatenation)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
gcc_assert (!bzero_first);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (total_orig)
{
/* Avoid the old/new stmt count heuristics. It should be
always beneficial. */
total_new[0] = 1;
total_orig[0] = 2;
}
if (split_stores)
{
unsigned HOST_WIDE_INT align_bitpos
= (group->start - align_base) & (group_align - 1);
unsigned HOST_WIDE_INT align = group_align;
if (align_bitpos)
align = least_bit_hwi (align_bitpos);
bytepos = group->start / BITS_PER_UNIT;
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
split_store *store
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
= new split_store (bytepos, group->width, align);
unsigned int first = 0;
find_constituent_stores (group, &store->orig_stores,
&first, group->start, group->width);
split_stores->safe_push (store);
}
return 1;
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned int ret = 0, first = 0;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT try_pos = bytepos;
if (total_orig)
{
unsigned int i;
store_immediate_info *info = group->stores[0];
total_new[0] = 0;
total_orig[0] = 1; /* The orig store. */
info = group->stores[0];
if (info->ops[0].base_addr)
total_orig[0]++;
if (info->ops[1].base_addr)
total_orig[0]++;
switch (info->rhs_code)
{
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
total_orig[0]++; /* The orig BIT_*_EXPR stmt. */
break;
default:
break;
}
total_orig[0] *= group->stores.length ();
FOR_EACH_VEC_ELT (group->stores, i, info)
{
total_new[0] += count_multiple_uses (info);
total_orig[0] += (info->bit_not_p
+ info->ops[0].bit_not_p
+ info->ops[1].bit_not_p);
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (!allow_unaligned_load)
for (int i = 0; i < 2; ++i)
if (group->load_align[i])
group_load_align = MIN (group_load_align, group->load_align[i]);
if (bzero_first)
{
store_immediate_info *gstore;
FOR_EACH_VEC_ELT (group->stores, first, gstore)
if (!gimple_clobber_p (gstore->stmt))
break;
++first;
ret = 1;
if (split_stores)
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
split_store *store
= new split_store (bytepos, gstore->bitsize, align_base);
store->orig_stores.safe_push (gstore);
store->orig = true;
any_orig = true;
split_stores->safe_push (store);
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
while (size > 0)
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if ((allow_unaligned_store || group_align <= BITS_PER_UNIT)
&& (group->mask[try_pos - bytepos] == (unsigned char) ~0U
|| (bzero_first && group->val[try_pos - bytepos] == 0)))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
/* Skip padding bytes. */
++try_pos;
size -= BITS_PER_UNIT;
continue;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned HOST_WIDE_INT try_bitpos = try_pos * BITS_PER_UNIT;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
unsigned int try_size = MAX_STORE_BITSIZE, nonmasked;
unsigned HOST_WIDE_INT align_bitpos
= (try_bitpos - align_base) & (group_align - 1);
unsigned HOST_WIDE_INT align = group_align;
bool found_orig = false;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (align_bitpos)
align = least_bit_hwi (align_bitpos);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (!allow_unaligned_store)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
try_size = MIN (try_size, align);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (!allow_unaligned_load)
{
/* If we can't do or don't want to do unaligned stores
as well as loads, we need to take the loads into account
as well. */
unsigned HOST_WIDE_INT load_align = group_load_align;
align_bitpos = (try_bitpos - align_base) & (load_align - 1);
if (align_bitpos)
load_align = least_bit_hwi (align_bitpos);
for (int i = 0; i < 2; ++i)
if (group->load_align[i])
{
align_bitpos
= known_alignment (try_bitpos
- group->stores[0]->bitpos
+ group->stores[0]->ops[i].bitpos
- group->load_align_base[i]);
if (align_bitpos & (group_load_align - 1))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
unsigned HOST_WIDE_INT a = least_bit_hwi (align_bitpos);
load_align = MIN (load_align, a);
}
}
try_size = MIN (try_size, load_align);
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
store_immediate_info *info
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
= find_constituent_stores (group, NULL, &first, try_bitpos, try_size);
if (info && !gimple_clobber_p (info->stmt))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
/* If there is just one original statement for the range, see if
we can just reuse the original store which could be even larger
than try_size. */
unsigned HOST_WIDE_INT stmt_end
= ROUND_UP (info->bitpos + info->bitsize, BITS_PER_UNIT);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
info = find_constituent_stores (group, NULL, &first, try_bitpos,
stmt_end - try_bitpos);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (info && info->bitpos >= try_bitpos)
{
store_immediate_info *info2 = NULL;
unsigned int first_copy = first;
if (info->bitpos > try_bitpos
&& stmt_end - try_bitpos <= try_size)
{
info2 = find_constituent_stores (group, NULL, &first_copy,
try_bitpos,
info->bitpos - try_bitpos);
gcc_assert (info2 == NULL || gimple_clobber_p (info2->stmt));
}
if (info2 == NULL && stmt_end - try_bitpos < try_size)
{
info2 = find_constituent_stores (group, NULL, &first_copy,
stmt_end,
(try_bitpos + try_size)
- stmt_end);
gcc_assert (info2 == NULL || gimple_clobber_p (info2->stmt));
}
if (info2 == NULL)
{
try_size = stmt_end - try_bitpos;
found_orig = true;
goto found;
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Approximate store bitsize for the case when there are no padding
bits. */
while (try_size > size)
try_size /= 2;
/* Now look for whole padding bytes at the end of that bitsize. */
for (nonmasked = try_size / BITS_PER_UNIT; nonmasked > 0; --nonmasked)
if (group->mask[try_pos - bytepos + nonmasked - 1]
!= (unsigned char) ~0U
&& (!bzero_first
|| group->val[try_pos - bytepos + nonmasked - 1] != 0))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
break;
if (nonmasked == 0 || (info && gimple_clobber_p (info->stmt)))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
/* If entire try_size range is padding, skip it. */
try_pos += try_size / BITS_PER_UNIT;
size -= try_size;
continue;
}
/* Otherwise try to decrease try_size if second half, last 3 quarters
etc. are padding. */
nonmasked *= BITS_PER_UNIT;
while (nonmasked <= try_size / 2)
try_size /= 2;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (!allow_unaligned_store && group_align > BITS_PER_UNIT)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
/* Now look for whole padding bytes at the start of that bitsize. */
unsigned int try_bytesize = try_size / BITS_PER_UNIT, masked;
for (masked = 0; masked < try_bytesize; ++masked)
if (group->mask[try_pos - bytepos + masked] != (unsigned char) ~0U
&& (!bzero_first
|| group->val[try_pos - bytepos + masked] != 0))
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
break;
masked *= BITS_PER_UNIT;
gcc_assert (masked < try_size);
if (masked >= try_size / 2)
{
while (masked >= try_size / 2)
{
try_size /= 2;
try_pos += try_size / BITS_PER_UNIT;
size -= try_size;
masked -= try_size;
}
/* Need to recompute the alignment, so just retry at the new
position. */
continue;
}
}
found:
++ret;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (split_stores)
{
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
split_store *store
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
= new split_store (try_pos, try_size, align);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
info = find_constituent_stores (group, &store->orig_stores,
&first, try_bitpos, try_size);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (info
&& !gimple_clobber_p (info->stmt)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
&& info->bitpos >= try_bitpos
&& info->bitpos + info->bitsize <= try_bitpos + try_size
&& (store->orig_stores.length () == 1
|| found_orig
|| (info->bitpos == try_bitpos
&& (info->bitpos + info->bitsize
== try_bitpos + try_size))))
{
store->orig = true;
any_orig = true;
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
split_stores->safe_push (store);
}
try_pos += try_size / BITS_PER_UNIT;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
size -= try_size;
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (total_orig)
{
unsigned int i;
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
split_store *store;
/* If we are reusing some original stores and any of the
original SSA_NAMEs had multiple uses, we need to subtract
those now before we add the new ones. */
if (total_new[0] && any_orig)
{
FOR_EACH_VEC_ELT (*split_stores, i, store)
if (store->orig)
total_new[0] -= count_multiple_uses (store->orig_stores[0]);
}
total_new[0] += ret; /* The new store. */
store_immediate_info *info = group->stores[0];
if (info->ops[0].base_addr)
total_new[0] += ret;
if (info->ops[1].base_addr)
total_new[0] += ret;
switch (info->rhs_code)
{
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
total_new[0] += ret; /* The new BIT_*_EXPR stmt. */
break;
default:
break;
}
FOR_EACH_VEC_ELT (*split_stores, i, store)
{
unsigned int j;
bool bit_not_p[3] = { false, false, false };
/* If all orig_stores have certain bit_not_p set, then
we'd use a BIT_NOT_EXPR stmt and need to account for it.
If some orig_stores have certain bit_not_p set, then
we'd use a BIT_XOR_EXPR with a mask and need to account for
it. */
FOR_EACH_VEC_ELT (store->orig_stores, j, info)
{
if (info->ops[0].bit_not_p)
bit_not_p[0] = true;
if (info->ops[1].bit_not_p)
bit_not_p[1] = true;
if (info->bit_not_p)
bit_not_p[2] = true;
}
total_new[0] += bit_not_p[0] + bit_not_p[1] + bit_not_p[2];
}
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
return ret;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Return the operation through which the operand IDX (if < 2) or
result (IDX == 2) should be inverted. If NOP_EXPR, no inversion
is done, if BIT_NOT_EXPR, all bits are inverted, if BIT_XOR_EXPR,
the bits should be xored with mask. */
static enum tree_code
invert_op (split_store *split_store, int idx, tree int_type, tree &mask)
{
unsigned int i;
store_immediate_info *info;
unsigned int cnt = 0;
bool any_paddings = false;
FOR_EACH_VEC_ELT (split_store->orig_stores, i, info)
{
bool bit_not_p = idx < 2 ? info->ops[idx].bit_not_p : info->bit_not_p;
if (bit_not_p)
{
++cnt;
tree lhs = gimple_assign_lhs (info->stmt);
if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
&& TYPE_PRECISION (TREE_TYPE (lhs)) < info->bitsize)
any_paddings = true;
}
}
mask = NULL_TREE;
if (cnt == 0)
return NOP_EXPR;
if (cnt == split_store->orig_stores.length () && !any_paddings)
return BIT_NOT_EXPR;
unsigned HOST_WIDE_INT try_bitpos = split_store->bytepos * BITS_PER_UNIT;
unsigned buf_size = split_store->size / BITS_PER_UNIT;
unsigned char *buf
= XALLOCAVEC (unsigned char, buf_size);
memset (buf, ~0U, buf_size);
FOR_EACH_VEC_ELT (split_store->orig_stores, i, info)
{
bool bit_not_p = idx < 2 ? info->ops[idx].bit_not_p : info->bit_not_p;
if (!bit_not_p)
continue;
/* Clear regions with bit_not_p and invert afterwards, rather than
clear regions with !bit_not_p, so that gaps in between stores aren't
set in the mask. */
unsigned HOST_WIDE_INT bitsize = info->bitsize;
unsigned HOST_WIDE_INT prec = bitsize;
unsigned int pos_in_buffer = 0;
if (any_paddings)
{
tree lhs = gimple_assign_lhs (info->stmt);
if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
&& TYPE_PRECISION (TREE_TYPE (lhs)) < bitsize)
prec = TYPE_PRECISION (TREE_TYPE (lhs));
}
if (info->bitpos < try_bitpos)
{
gcc_assert (info->bitpos + bitsize > try_bitpos);
if (!BYTES_BIG_ENDIAN)
{
if (prec <= try_bitpos - info->bitpos)
continue;
prec -= try_bitpos - info->bitpos;
}
bitsize -= try_bitpos - info->bitpos;
if (BYTES_BIG_ENDIAN && prec > bitsize)
prec = bitsize;
}
else
pos_in_buffer = info->bitpos - try_bitpos;
if (prec < bitsize)
{
/* If this is a bool inversion, invert just the least significant
prec bits rather than all bits of it. */
if (BYTES_BIG_ENDIAN)
{
pos_in_buffer += bitsize - prec;
if (pos_in_buffer >= split_store->size)
continue;
}
bitsize = prec;
}
if (pos_in_buffer + bitsize > split_store->size)
bitsize = split_store->size - pos_in_buffer;
unsigned char *p = buf + (pos_in_buffer / BITS_PER_UNIT);
if (BYTES_BIG_ENDIAN)
clear_bit_region_be (p, (BITS_PER_UNIT - 1
- (pos_in_buffer % BITS_PER_UNIT)), bitsize);
else
clear_bit_region (p, pos_in_buffer % BITS_PER_UNIT, bitsize);
}
for (unsigned int i = 0; i < buf_size; ++i)
buf[i] = ~buf[i];
mask = native_interpret_expr (int_type, buf, buf_size);
return BIT_XOR_EXPR;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Given a merged store group GROUP output the widened version of it.
The store chain is against the base object BASE.
Try store sizes of at most MAX_STORE_BITSIZE bits wide and don't output
unaligned stores for STRICT_ALIGNMENT targets or if it's too expensive.
Make sure that the number of statements output is less than the number of
original statements. If a better sequence is possible emit it and
return true. */
bool
imm_store_chain_info::output_merged_store (merged_store_group *group)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
const unsigned HOST_WIDE_INT start_byte_pos
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
= group->bitregion_start / BITS_PER_UNIT;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned int orig_num_stmts = group->stores.length ();
if (orig_num_stmts < 2)
return false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
bool allow_unaligned_store
Apply mechanical replacement (generated patch). 2019-11-12 Martin Liska <mliska@suse.cz> * asan.c (asan_sanitize_stack_p): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. (asan_sanitize_allocas_p): Likewise. (asan_emit_stack_protection): Likewise. (asan_protect_global): Likewise. (instrument_derefs): Likewise. (instrument_builtin_call): Likewise. (asan_expand_mark_ifn): Likewise. * auto-profile.c (auto_profile): Likewise. * bb-reorder.c (copy_bb_p): Likewise. (duplicate_computed_gotos): Likewise. * builtins.c (inline_expand_builtin_string_cmp): Likewise. * cfgcleanup.c (try_crossjump_to_edge): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.c (defer_stack_allocation): Likewise. (stack_protect_classify_type): Likewise. (pass_expand::execute): Likewise. * cfgloopanal.c (expected_loop_iterations_unbounded): Likewise. (estimate_reg_pressure_cost): Likewise. * cgraph.c (cgraph_edge::maybe_hot_p): Likewise. * combine.c (combine_instructions): Likewise. (record_value_for_reg): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_option_validate_param): Likewise. (aarch64_option_default_params): Likewise. * common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise. * common/config/sh/sh-common.c (sh_option_default_params): Likewise. * config/aarch64/aarch64.c (aarch64_output_probe_stack_range): Likewise. (aarch64_allocate_and_probe_stack_space): Likewise. (aarch64_expand_epilogue): Likewise. (aarch64_override_options_internal): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arm/arm.c (arm_option_override): Likewise. (arm_valid_target_attribute_p): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (get_probe_interval): Likewise. (ix86_adjust_stack_and_probe_stack_clash): Likewise. (ix86_max_noce_ifcvt_seq_cost): Likewise. * config/ia64/ia64.c (ia64_adjust_cost): Likewise. * config/rs6000/rs6000-logue.c (get_stack_clash_protection_probe_interval): Likewise. (get_stack_clash_protection_guard_size): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/s390/s390.c (allocate_stack_space): Likewise. (s390_emit_prologue): Likewise. (s390_option_override_internal): Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/visium/visium.c (visium_option_override): Likewise. * coverage.c (get_coverage_counts): Likewise. (coverage_compute_profile_id): Likewise. (coverage_begin_function): Likewise. (coverage_end_function): Likewise. * cse.c (cse_find_path): Likewise. (cse_extended_basic_block): Likewise. (cse_main): Likewise. * cselib.c (cselib_invalidate_mem): Likewise. * dse.c (dse_step1): Likewise. * emit-rtl.c (set_new_first_and_last_insn): Likewise. (get_max_insn_count): Likewise. (make_debug_insn_raw): Likewise. (init_emit): Likewise. * explow.c (compute_stack_clash_protection_loop_data): Likewise. * final.c (compute_alignments): Likewise. * fold-const.c (fold_range_test): Likewise. (fold_truth_andor): Likewise. (tree_single_nonnegative_warnv_p): Likewise. (integer_valued_real_single_p): Likewise. * gcse.c (want_to_gcse_p): Likewise. (prune_insertions_deletions): Likewise. (hoist_code): Likewise. (gcse_or_cprop_is_too_expensive): Likewise. * ggc-common.c: Likewise. * ggc-page.c (ggc_collect): Likewise. * gimple-loop-interchange.cc (MAX_NUM_STMT): Likewise. (MAX_DATAREFS): Likewise. (OUTER_STRIDE_RATIO): Likewise. * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise. * gimple-loop-versioning.cc (loop_versioning::max_insns_for_loop): Likewise. * gimple-ssa-split-paths.c (is_feasible_trace): Likewise. * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (imm_store_chain_info::output_merged_store): Likewise. (pass_store_merging::process_store): Likewise. * gimple-ssa-strength-reduction.c (find_basis_for_base_expr): Likewise. * graphite-isl-ast-to-gimple.c (class translate_isl_ast_to_gimple): Likewise. (scop_to_isl_ast): Likewise. * graphite-optimize-isl.c (get_schedule_for_node_st): Likewise. (optimize_isl): Likewise. * graphite-scop-detection.c (build_scops): Likewise. * haifa-sched.c (set_modulo_params): Likewise. (rank_for_schedule): Likewise. (model_add_to_worklist): Likewise. (model_promote_insn): Likewise. (model_choose_insn): Likewise. (queue_to_ready): Likewise. (autopref_multipass_dfa_lookahead_guard): Likewise. (schedule_block): Likewise. (sched_init): Likewise. * hsa-gen.c (init_prologue): Likewise. * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Likewise. (cond_move_process_if_block): Likewise. * ipa-cp.c (ipcp_lattice::add_value): Likewise. (merge_agg_lats_step): Likewise. (devirtualization_time_bonus): Likewise. (hint_time_bonus): Likewise. (incorporate_penalties): Likewise. (good_cloning_opportunity_p): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (decompose_param_expr): Likewise. (set_switch_stmt_execution_predicate): Likewise. (analyze_function_body): Likewise. (compute_fn_summary): Likewise. * ipa-inline-analysis.c (estimate_growth): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (inline_insns_single): Likewise. (inline_insns_auto): Likewise. (can_inline_edge_by_limits_p): Likewise. (want_early_inline_function_p): Likewise. (big_speedup_p): Likewise. (want_inline_small_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (edge_badness): Likewise. (recursive_inlining): Likewise. (compute_max_insns): Likewise. (early_inliner): Likewise. * ipa-polymorphic-call.c (csftc_abort_walking_p): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (determine_known_aggregate_parts): Likewise. (ipa_analyze_node): Likewise. (ipcp_transform_function): Likewise. * ipa-split.c (consider_split): Likewise. * ipa-sra.c (allocate_access): Likewise. (process_scan_results): Likewise. (ipa_sra_summarize_function): Likewise. (pull_accesses_from_callee): Likewise. * ira-build.c (loop_compare_func): Likewise. (mark_loops_for_removal): Likewise. * ira-conflicts.c (build_conflict_bit_table): Likewise. * loop-doloop.c (doloop_optimize): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. (move_loop_invariants): Likewise. * loop-unroll.c (decide_unroll_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. (expand_var_during_unrolling): Likewise. * lra-assigns.c (spill_for): Likewise. * lra-constraints.c (EBB_PROBABILITY_CUTOFF): Likewise. * modulo-sched.c (sms_schedule): Likewise. (DFA_HISTORY): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (common_handle_option): Likewise. * postreload-gcse.c (eliminate_partially_redundant_load): Likewise. (if): Likewise. * predict.c (get_hot_bb_threshold): Likewise. (maybe_hot_count_p): Likewise. (probably_never_executed): Likewise. (predictable_edge_p): Likewise. (predict_loops): Likewise. (expr_expected_value_1): Likewise. (tree_predict_by_opcode): Likewise. (handle_missing_profiles): Likewise. * reload.c (find_equiv_reg): Likewise. * reorg.c (redundant_insn): Likewise. * resource.c (mark_target_live_regs): Likewise. (incr_ticks_for_insn): Likewise. * sanopt.c (pass_sanopt::execute): Likewise. * sched-deps.c (sched_analyze_1): Likewise. (sched_analyze_2): Likewise. (sched_analyze_insn): Likewise. (deps_analyze_insn): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (find_single_block_region): Likewise. (too_large): Likewise. (haifa_find_rgns): Likewise. (extend_rgns): Likewise. (new_ready): Likewise. (schedule_region): Likewise. (sched_rgn_init): Likewise. * sel-sched-ir.c (make_region_from_loop): Likewise. * sel-sched-ir.h (MAX_WS): Likewise. * sel-sched.c (process_pipelined_exprs): Likewise. (sel_setup_region_sched_flags): Likewise. * shrink-wrap.c (try_shrink_wrapping): Likewise. * targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise. * toplev.c (print_version): Likewise. (process_options): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_log_add): Likewise. * tree-chrec.c (chrec_fold_plus_1): Likewise. * tree-data-ref.c (split_constant_offset): Likewise. (compute_all_dependences): Likewise. * tree-if-conv.c (MAX_PHI_ARG_NUM): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. * tree-loop-distribution.c (MAX_DATAREFS_NUM): Likewise. * tree-parloops.c (MIN_PER_THREAD): Likewise. (create_parallel_loop): Likewise. * tree-predcom.c (determine_unroll_factor): Likewise. * tree-scalar-evolution.c (instantiate_scev_r): Likewise. * tree-sra.c (analyze_all_variable_accesses): Likewise. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Likewise. * tree-ssa-dse.c (setup_live_bytes_from_ref): Likewise. (dse_optimize_redundant_stores): Likewise. (dse_classify_store): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise. * tree-ssa-loop-im.c (LIM_EXPENSIVE): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise. (CONSIDER_ALL_CANDIDATES_BOUND): Likewise. (MAX_CONSIDERED_GROUPS): Likewise. (ALWAYS_PRUNE_CAND_SET_BOUND): Likewise. * tree-ssa-loop-manip.c (can_unroll_loop_p): Likewise. * tree-ssa-loop-niter.c (MAX_ITERATIONS_TO_TRACK): Likewise. * tree-ssa-loop-prefetch.c (PREFETCH_BLOCK): Likewise. (L1_CACHE_SIZE_BYTES): Likewise. (L2_CACHE_SIZE_BYTES): Likewise. (should_issue_prefetch_p): Likewise. (schedule_prefetches): Likewise. (determine_unroll_factor): Likewise. (volume_of_references): Likewise. (add_subscript_strides): Likewise. (self_reuse_distance): Likewise. (mem_ref_count_reasonable_p): Likewise. (insn_to_prefetch_ratio_too_small_p): Likewise. (loop_prefetch_arrays): Likewise. (tree_ssa_prefetch_arrays): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. (convert_mult_to_fma): Likewise. (math_opts_dom_walker::after_dom_children): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. (hoist_adjacent_loads): Likewise. (gate_hoist_loads): Likewise. * tree-ssa-pre.c (translate_vuse_through_block): Likewise. (compute_partial_antic_aux): Likewise. * tree-ssa-reassoc.c (get_reassociation_width): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. (do_rpo_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. * tree-ssa-sink.c (select_best_block): Likewise. * tree-ssa-strlen.c (new_stridx): Likewise. (new_addr_stridx): Likewise. (get_range_strlen_dynamic): Likewise. (class ssa_name_limit_t): Likewise. * tree-ssa-structalias.c (push_fields_onto_fieldstack): Likewise. (create_variable_info_for_1): Likewise. (init_alias_vars): Likewise. * tree-ssa-tail-merge.c (find_clusters_1): Likewise. (tail_merge_optimize): Likewise. * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Likewise. (thread_jumps::fsm_find_control_statement_thread_paths): Likewise. (thread_jumps::find_jump_threads_backwards): Likewise. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Likewise. * tree-ssa-uninit.c (compute_control_dep_chain): Likewise. * tree-switch-conversion.c (switch_conversion::check_range): Likewise. (jump_table_cluster::can_be_handled): Likewise. * tree-switch-conversion.h (jump_table_cluster::case_values_threshold): Likewise. (SWITCH_CONVERSION_BRANCH_RATIO): Likewise. (param_switch_conversion_branch_ratio): Likewise. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_analyze_loop_costing): Likewise. (vect_get_datarefs_in_loop): Likewise. (vect_analyze_loop): Likewise. * tree-vect-slp.c (vect_slp_bb): Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (vrp_prop::check_mem_ref): Likewise. * tree.c (wide_int_to_tree_1): Likewise. (cache_integer_cst): Likewise. * var-tracking.c (EXPR_USE_DEPTH): Likewise. (reverse_op): Likewise. (vt_find_locations): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_parse_gimple_body): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_hints::namespace_hints): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * typeck.c (comptypes): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-partition.c (lto_balanced_map): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * lto.c (do_whole_program_analysis): Likewise. From-SVN: r278085
2019-11-12 11:08:40 +01:00
= !STRICT_ALIGNMENT && param_store_merging_allow_unaligned;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
bool allow_unaligned_load = allow_unaligned_store;
bool bzero_first = false;
store_immediate_info *store;
unsigned int num_clobber_stmts = 0;
if (group->stores[0]->rhs_code == INTEGER_CST)
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
unsigned int i;
FOR_EACH_VEC_ELT (group->stores, i, store)
if (gimple_clobber_p (store->stmt))
num_clobber_stmts++;
else if (TREE_CODE (gimple_assign_rhs1 (store->stmt)) == CONSTRUCTOR
&& CONSTRUCTOR_NELTS (gimple_assign_rhs1 (store->stmt)) == 0
&& group->start == store->bitpos
&& group->width == store->bitsize
&& (group->start % BITS_PER_UNIT) == 0
&& (group->width % BITS_PER_UNIT) == 0)
{
bzero_first = true;
break;
}
else
break;
FOR_EACH_VEC_ELT_FROM (group->stores, i, store, i)
if (gimple_clobber_p (store->stmt))
num_clobber_stmts++;
if (num_clobber_stmts == orig_num_stmts)
return false;
orig_num_stmts -= num_clobber_stmts;
}
if (allow_unaligned_store || bzero_first)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
/* If unaligned stores are allowed, see how many stores we'd emit
for unaligned and how many stores we'd emit for aligned stores.
Only use unaligned stores if it allows fewer stores than aligned.
Similarly, if there is a whole region clear first, prefer expanding
it together compared to expanding clear first followed by merged
further stores. */
unsigned cnt[4] = { ~0U, ~0U, ~0U, ~0U };
int pass_min = 0;
for (int pass = 0; pass < 4; ++pass)
{
if (!allow_unaligned_store && (pass & 1) != 0)
continue;
if (!bzero_first && (pass & 2) != 0)
continue;
cnt[pass] = split_group (group, (pass & 1) != 0,
allow_unaligned_load, (pass & 2) != 0,
NULL, NULL, NULL);
if (cnt[pass] < cnt[pass_min])
pass_min = pass;
}
if ((pass_min & 1) == 0)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
allow_unaligned_store = false;
if ((pass_min & 2) == 0)
bzero_first = false;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
auto_vec<class split_store *, 32> split_stores;
split_store *split_store;
unsigned total_orig, total_new, i;
split_group (group, allow_unaligned_store, allow_unaligned_load, bzero_first,
&split_stores, &total_orig, &total_new);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* Determine if there is a clobber covering the whole group at the start,
followed by proposed split stores that cover the whole group. In that
case, prefer the transformation even if
split_stores.length () == orig_num_stmts. */
bool clobber_first = false;
if (num_clobber_stmts
&& gimple_clobber_p (group->stores[0]->stmt)
&& group->start == group->stores[0]->bitpos
&& group->width == group->stores[0]->bitsize
&& (group->start % BITS_PER_UNIT) == 0
&& (group->width % BITS_PER_UNIT) == 0)
{
clobber_first = true;
unsigned HOST_WIDE_INT pos = group->start / BITS_PER_UNIT;
FOR_EACH_VEC_ELT (split_stores, i, split_store)
if (split_store->bytepos != pos)
{
clobber_first = false;
break;
}
else
pos += split_store->size / BITS_PER_UNIT;
if (pos != (group->start + group->width) / BITS_PER_UNIT)
clobber_first = false;
}
if (split_stores.length () >= orig_num_stmts + clobber_first)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
{
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
/* We didn't manage to reduce the number of statements. Bail out. */
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Exceeded original number of stmts (%u)."
" Not profitable to emit new sequence.\n",
orig_num_stmts);
FOR_EACH_VEC_ELT (split_stores, i, split_store)
delete split_store;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
return false;
}
if (total_orig <= total_new)
{
/* If number of estimated new statements is above estimated original
statements, bail out too. */
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Estimated number of original stmts (%u)"
" not larger than estimated number of new"
" stmts (%u).\n",
total_orig, total_new);
FOR_EACH_VEC_ELT (split_stores, i, split_store)
delete split_store;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
return false;
}
if (group->stores[0]->rhs_code == INTEGER_CST)
{
bool all_orig = true;
FOR_EACH_VEC_ELT (split_stores, i, split_store)
if (!split_store->orig)
{
all_orig = false;
break;
}
if (all_orig)
{
unsigned int cnt = split_stores.length ();
store_immediate_info *store;
FOR_EACH_VEC_ELT (group->stores, i, store)
if (gimple_clobber_p (store->stmt))
++cnt;
/* Punt if we wouldn't make any real changes, i.e. keep all
orig stmts + all clobbers. */
if (cnt == group->stores.length ())
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Exceeded original number of stmts (%u)."
" Not profitable to emit new sequence.\n",
orig_num_stmts);
FOR_EACH_VEC_ELT (split_stores, i, split_store)
delete split_store;
return false;
}
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple_stmt_iterator last_gsi = gsi_for_stmt (group->last_stmt);
gimple_seq seq = NULL;
tree last_vdef, new_vuse;
last_vdef = gimple_vdef (group->last_stmt);
new_vuse = gimple_vuse (group->last_stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
tree bswap_res = NULL_TREE;
/* Clobbers are not removed. */
if (gimple_clobber_p (group->last_stmt))
{
new_vuse = make_ssa_name (gimple_vop (cfun), group->last_stmt);
gimple_set_vdef (group->last_stmt, new_vuse);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (group->stores[0]->rhs_code == LROTATE_EXPR
|| group->stores[0]->rhs_code == NOP_EXPR)
{
tree fndecl = NULL_TREE, bswap_type = NULL_TREE, load_type;
gimple *ins_stmt = group->stores[0]->ins_stmt;
struct symbolic_number *n = &group->stores[0]->n;
bool bswap = group->stores[0]->rhs_code == LROTATE_EXPR;
switch (n->range)
{
case 16:
load_type = bswap_type = uint16_type_node;
break;
case 32:
load_type = uint32_type_node;
if (bswap)
{
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
bswap_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
break;
case 64:
load_type = uint64_type_node;
if (bswap)
{
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64);
bswap_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
}
break;
default:
gcc_unreachable ();
}
/* If the loads have each vuse of the corresponding store,
we've checked the aliasing already in try_coalesce_bswap and
we want to sink the need load into seq. So need to use new_vuse
on the load. */
if (n->base_addr)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
if (n->vuse == NULL)
{
n->vuse = new_vuse;
ins_stmt = NULL;
}
else
/* Update vuse in case it has changed by output_merged_stores. */
n->vuse = gimple_vuse (ins_stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
}
bswap_res = bswap_replace (gsi_start (seq), ins_stmt, fndecl,
bswap: Recognize (int) __builtin_bswap64 (arg) idioms or __builtin_bswap?? (arg) & mask [PR86723] The following patch recognizes in the bswap pass (only there for now, haven't done it for store merging pass yet) code sequences that can be handled by (int32) __builtin_bswap64 (arg), i.e. where we have 0x05060708 n->n with 64-bit non-memory argument (if it is memory, we can just load the 32-bit at 4 bytes into the address and n->n would be 0x01020304; and only 64 -> 32 bit, because 64 -> 16 bit or 32 -> 16 bit would mean only two bytes in the result and probably not worth it), and furthermore the case where we have in the 0x0102030405060708 etc. numbers some bytes 0 (i.e. known to contain zeros rather than source bytes), as long as we have at least two original bytes in the right positions (and no unknown bytes). This can be handled by __builtin_bswap64 (arg) & 0xff0000ffffff00ffULL etc. The latter change is the reason why counting the bswap messages doesn't work too well in optimize-bswap* tests anymore, while the pass iterates from end of basic block towards start, it will often match both the bswap at the end and some of the earlier bswaps with some masks (not a problem generally, we'll just DCE it away whenever possible). The pass right now doesn't handle __builtin_bswap* calls in the pattern matching (which is the reason why it operates backwards), but it uses FOR_EACH_BB_FN (bb, fun) order of handling blocks and matched sequences can span multiple blocks, so I was worried about cases like: void bar (unsigned long long); unsigned long long foo (unsigned long long value, int x) { unsigned long long tmp = (((value & 0x00000000000000ffull) << 56) | ((value & 0x000000000000ff00ull) << 40) | ((value & 0x00000000ff000000ull) << 8)); if (x) bar (tmp); return (tmp | ((value & 0x000000ff00000000ull) >> 8) | ((value & 0x0000ff0000000000ull) >> 24) | ((value & 0x0000000000ff0000ull) << 24) | ((value & 0x00ff000000000000ull) >> 40) | ((value & 0xff00000000000000ull) >> 56)); } but it seems we handle even that fine, while bb2 ending in GIMPLE_COND is processed first, we recognize there a __builtin_bswap64 (value) & mask1, in the last bb we recognize tmp | (__builtin_bswap64 (value) & mask2) and PRE optimizes that into t = __builtin_bswap64 (value); tmp = t & mask1; in the first bb and return t; in the last one. 2021-08-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/86723 * gimple-ssa-store-merging.c (find_bswap_or_nop_finalize): Add cast64_to_32 argument, set *cast64_to_32 to false, unless n is non-memory permutation of 64-bit src which only has bytes of 0 or [5..8] and n->range is 4. (find_bswap_or_nop): Add cast64_to_32 and mask arguments, adjust find_bswap_or_nop_finalize caller, support bswap with some bytes zeroed, as long as at least two bytes are not zeroed. (bswap_replace): Add mask argument and handle masking of bswap result. (maybe_optimize_vector_constructor): Adjust find_bswap_or_nop caller, punt if cast64_to_32 or mask is not all ones. (pass_optimize_bswap::execute): Adjust find_bswap_or_nop_finalize caller, for now punt if cast64_to_32. * gcc.dg/pr86723.c: New test. * gcc.target/i386/pr86723.c: New test. * gcc.dg/optimize-bswapdi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap64 calls. * gcc.dg/optimize-bswapdi-2.c: Likewise. * gcc.dg/optimize-bswapsi-1.c: Use -fdump-tree-optimized instead of -fdump-tree-bswap and scan for number of __builtin_bswap32 calls. * gcc.dg/optimize-bswapsi-5.c: Likewise. * gcc.dg/optimize-bswapsi-3.c: Likewise. Expect one __builtin_bswap32 call instead of zero.
2021-08-23 11:52:06 +02:00
bswap_type, load_type, n, bswap,
~(uint64_t) 0);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gcc_assert (bswap_res);
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple *stmt = NULL;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
auto_vec<gimple *, 32> orig_stmts;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple_seq this_seq;
tree addr = force_gimple_operand_1 (unshare_expr (base_addr), &this_seq,
is_gimple_mem_ref_addr, NULL_TREE);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
gimple_seq_add_seq_without_update (&seq, this_seq);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree load_addr[2] = { NULL_TREE, NULL_TREE };
gimple_seq load_seq[2] = { NULL, NULL };
gimple_stmt_iterator load_gsi[2] = { gsi_none (), gsi_none () };
for (int j = 0; j < 2; ++j)
{
store_operand_info &op = group->stores[0]->ops[j];
if (op.base_addr == NULL_TREE)
continue;
store_immediate_info *infol = group->stores.last ();
if (gimple_vuse (op.stmt) == gimple_vuse (infol->ops[j].stmt))
{
/* We can't pick the location randomly; while we've verified
all the loads have the same vuse, they can be still in different
basic blocks and we need to pick the one from the last bb:
int x = q[0];
if (x == N) return;
int y = q[1];
p[0] = x;
p[1] = y;
otherwise if we put the wider load at the q[0] load, we might
segfault if q[1] is not mapped. */
basic_block bb = gimple_bb (op.stmt);
gimple *ostmt = op.stmt;
store_immediate_info *info;
FOR_EACH_VEC_ELT (group->stores, i, info)
{
gimple *tstmt = info->ops[j].stmt;
basic_block tbb = gimple_bb (tstmt);
if (dominated_by_p (CDI_DOMINATORS, tbb, bb))
{
ostmt = tstmt;
bb = tbb;
}
}
load_gsi[j] = gsi_for_stmt (ostmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
load_addr[j]
= force_gimple_operand_1 (unshare_expr (op.base_addr),
&load_seq[j], is_gimple_mem_ref_addr,
NULL_TREE);
}
else if (operand_equal_p (base_addr, op.base_addr, 0))
load_addr[j] = addr;
else
{
load_addr[j]
= force_gimple_operand_1 (unshare_expr (op.base_addr),
&this_seq, is_gimple_mem_ref_addr,
NULL_TREE);
gimple_seq_add_seq_without_update (&seq, this_seq);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
FOR_EACH_VEC_ELT (split_stores, i, split_store)
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
const unsigned HOST_WIDE_INT try_size = split_store->size;
const unsigned HOST_WIDE_INT try_pos = split_store->bytepos;
const unsigned HOST_WIDE_INT try_bitpos = try_pos * BITS_PER_UNIT;
const unsigned HOST_WIDE_INT try_align = split_store->align;
const unsigned HOST_WIDE_INT try_offset = try_pos - start_byte_pos;
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
tree dest, src;
location_t loc;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (split_store->orig)
{
/* If there is just a single non-clobber constituent store
which covers the whole area, just reuse the lhs and rhs. */
gimple *orig_stmt = NULL;
store_immediate_info *store;
unsigned int j;
FOR_EACH_VEC_ELT (split_store->orig_stores, j, store)
if (!gimple_clobber_p (store->stmt))
{
orig_stmt = store->stmt;
break;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
dest = gimple_assign_lhs (orig_stmt);
src = gimple_assign_rhs1 (orig_stmt);
loc = gimple_location (orig_stmt);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
}
else
{
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_immediate_info *info;
unsigned short clique, base;
unsigned int k;
FOR_EACH_VEC_ELT (split_store->orig_stores, k, info)
orig_stmts.safe_push (info->stmt);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
tree offset_type
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
= get_alias_type_for_stmts (orig_stmts, false, &clique, &base);
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
tree dest_type;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
loc = get_location_for_stmts (orig_stmts);
orig_stmts.truncate (0);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (group->string_concatenation)
dest_type
= build_array_type_nelts (char_type_node,
try_size / BITS_PER_UNIT);
else
{
dest_type = build_nonstandard_integer_type (try_size, UNSIGNED);
dest_type = build_aligned_type (dest_type, try_align);
}
dest = fold_build2 (MEM_REF, dest_type, addr,
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
build_int_cst (offset_type, try_pos));
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (TREE_CODE (dest) == MEM_REF)
{
MR_DEPENDENCE_CLIQUE (dest) = clique;
MR_DEPENDENCE_BASE (dest) = base;
}
tree mask;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (bswap_res || group->string_concatenation)
mask = integer_zero_node;
else
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
mask = native_interpret_expr (dest_type,
group->mask + try_offset,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
group->buf_size);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree ops[2];
for (int j = 0;
j < 1 + (split_store->orig_stores[0]->ops[1].val != NULL_TREE);
++j)
{
store_operand_info &op = split_store->orig_stores[0]->ops[j];
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (bswap_res)
ops[j] = bswap_res;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
else if (group->string_concatenation)
{
ops[j] = build_string (try_size / BITS_PER_UNIT,
(const char *) group->val + try_offset);
TREE_TYPE (ops[j]) = dest_type;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
else if (op.base_addr)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
FOR_EACH_VEC_ELT (split_store->orig_stores, k, info)
orig_stmts.safe_push (info->ops[j].stmt);
offset_type = get_alias_type_for_stmts (orig_stmts, true,
&clique, &base);
location_t load_loc = get_location_for_stmts (orig_stmts);
orig_stmts.truncate (0);
unsigned HOST_WIDE_INT load_align = group->load_align[j];
unsigned HOST_WIDE_INT align_bitpos
= known_alignment (try_bitpos
- split_store->orig_stores[0]->bitpos
+ op.bitpos);
if (align_bitpos & (load_align - 1))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
load_align = least_bit_hwi (align_bitpos);
tree load_int_type
= build_nonstandard_integer_type (try_size, UNSIGNED);
load_int_type
= build_aligned_type (load_int_type, load_align);
poly_uint64 load_pos
= exact_div (try_bitpos
- split_store->orig_stores[0]->bitpos
+ op.bitpos,
BITS_PER_UNIT);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
ops[j] = fold_build2 (MEM_REF, load_int_type, load_addr[j],
build_int_cst (offset_type, load_pos));
if (TREE_CODE (ops[j]) == MEM_REF)
{
MR_DEPENDENCE_CLIQUE (ops[j]) = clique;
MR_DEPENDENCE_BASE (ops[j]) = base;
}
if (!integer_zerop (mask))
middle-end: add support for per-location warning groups. gcc/ChangeLog: * builtins.c (warn_string_no_nul): Replace uses of TREE_NO_WARNING, gimple_no_warning_p and gimple_set_no_warning with warning_suppressed_p, and suppress_warning. (c_strlen): Same. (maybe_warn_for_bound): Same. (warn_for_access): Same. (check_access): Same. (expand_builtin_strncmp): Same. (fold_builtin_varargs): Same. * calls.c (maybe_warn_nonstring_arg): Same. (maybe_warn_rdwr_sizes): Same. * cfgexpand.c (expand_call_stmt): Same. * cgraphunit.c (check_global_declaration): Same. * fold-const.c (fold_undefer_overflow_warnings): Same. (fold_truth_not_expr): Same. (fold_unary_loc): Same. (fold_checksum_tree): Same. * gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Same. (array_bounds_checker::check_mem_ref): Same. (array_bounds_checker::check_addr_expr): Same. (array_bounds_checker::check_array_bounds): Same. * gimple-expr.c (copy_var_decl): Same. * gimple-fold.c (gimple_fold_builtin_strcpy): Same. (gimple_fold_builtin_strncat): Same. (gimple_fold_builtin_stxcpy_chk): Same. (gimple_fold_builtin_stpcpy): Same. (gimple_fold_builtin_sprintf): Same. (fold_stmt_1): Same. * gimple-ssa-isolate-paths.c (diag_returned_locals): Same. * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same. * gimple-ssa-sprintf.c (handle_printf_call): Same. * gimple-ssa-store-merging.c (imm_store_chain_info::output_merged_store): Same. * gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same. * gimple-ssa-warn-restrict.h: Adjust declarations. (maybe_diag_access_bounds): Replace uses of TREE_NO_WARNING, gimple_no_warning_p and gimple_set_no_warning with warning_suppressed_p, and suppress_warning. (check_call): Same. (check_bounds_or_overlap): Same. * gimple.c (gimple_build_call_from_tree): Same. * gimplify.c (gimplify_return_expr): Same. (gimplify_cond_expr): Same. (gimplify_modify_expr_complex_part): Same. (gimplify_modify_expr): Same. (gimple_push_cleanup): Same. (gimplify_expr): Same. * omp-expand.c (expand_omp_for_generic): Same. (expand_omp_taskloop_for_outer): Same. * omp-low.c (lower_rec_input_clauses): Same. (lower_lastprivate_clauses): Same. (lower_send_clauses): Same. (lower_omp_target): Same. * tree-cfg.c (pass_warn_function_return::execute): Same. * tree-complex.c (create_one_component_var): Same. * tree-inline.c (remap_gimple_op_r): Same. (copy_tree_body_r): Same. (declare_return_variable): Same. (expand_call_inline): Same. * tree-nested.c (lookup_field_for_decl): Same. * tree-sra.c (create_access_replacement): Same. (generate_subtree_copies): Same. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same. * tree-ssa-forwprop.c (combine_cond_expr_cond): Same. * tree-ssa-loop-ch.c (ch_base::copy_headers): Same. * tree-ssa-loop-im.c (execute_sm): Same. * tree-ssa-phiopt.c (cond_store_replacement): Same. * tree-ssa-strlen.c (maybe_warn_overflow): Same. (handle_builtin_strcpy): Same. (maybe_diag_stxncpy_trunc): Same. (handle_builtin_stxncpy_strncat): Same. (handle_builtin_strcat): Same. * tree-ssa-uninit.c (get_no_uninit_warning): Same. (set_no_uninit_warning): Same. (uninit_undefined_value_p): Same. (warn_uninit): Same. (maybe_warn_operand): Same. * tree-vrp.c (compare_values_warnv): Same. * vr-values.c (vr_values::extract_range_for_var_from_comparison_expr): Same. (test_for_singularity): Same. * gimple.h (warning_suppressed_p): New function. (suppress_warning): Same. (copy_no_warning): Same. (gimple_set_block): Call gimple_set_location. (gimple_set_location): Call copy_warning.
2021-06-25 03:22:06 +02:00
{
/* The load might load some bits (that will be masked
off later on) uninitialized, avoid -W*uninitialized
warnings in that case. */
suppress_warning (ops[j], OPT_Wuninitialized);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type), ops[j]);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
gimple_set_location (stmt, load_loc);
if (gsi_bb (load_gsi[j]))
{
gimple_set_vuse (stmt, gimple_vuse (op.stmt));
gimple_seq_add_stmt_without_update (&load_seq[j], stmt);
}
else
{
gimple_set_vuse (stmt, new_vuse);
gimple_seq_add_stmt_without_update (&seq, stmt);
}
ops[j] = gimple_assign_lhs (stmt);
tree xor_mask;
enum tree_code inv_op
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
= invert_op (split_store, j, dest_type, xor_mask);
if (inv_op != NOP_EXPR)
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
inv_op, ops[j], xor_mask);
gimple_set_location (stmt, load_loc);
ops[j] = gimple_assign_lhs (stmt);
if (gsi_bb (load_gsi[j]))
gimple_seq_add_stmt_without_update (&load_seq[j],
stmt);
else
gimple_seq_add_stmt_without_update (&seq, stmt);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
else
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
ops[j] = native_interpret_expr (dest_type,
group->val + try_offset,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
group->buf_size);
}
switch (split_store->orig_stores[0]->rhs_code)
{
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
FOR_EACH_VEC_ELT (split_store->orig_stores, k, info)
{
tree rhs1 = gimple_assign_rhs1 (info->stmt);
orig_stmts.safe_push (SSA_NAME_DEF_STMT (rhs1));
}
location_t bit_loc;
bit_loc = get_location_for_stmts (orig_stmts);
orig_stmts.truncate (0);
stmt
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
= gimple_build_assign (make_ssa_name (dest_type),
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
split_store->orig_stores[0]->rhs_code,
ops[0], ops[1]);
gimple_set_location (stmt, bit_loc);
/* If there is just one load and there is a separate
load_seq[0], emit the bitwise op right after it. */
if (load_addr[1] == NULL_TREE && gsi_bb (load_gsi[0]))
gimple_seq_add_stmt_without_update (&load_seq[0], stmt);
/* Otherwise, if at least one load is in seq, we need to
emit the bitwise op right before the store. If there
are two loads and are emitted somewhere else, it would
be better to emit the bitwise op as early as possible;
we don't track where that would be possible right now
though. */
else
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
tree xor_mask;
enum tree_code inv_op;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
inv_op = invert_op (split_store, 2, dest_type, xor_mask);
if (inv_op != NOP_EXPR)
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
inv_op, src, xor_mask);
gimple_set_location (stmt, bit_loc);
if (load_addr[1] == NULL_TREE && gsi_bb (load_gsi[0]))
gimple_seq_add_stmt_without_update (&load_seq[0], stmt);
else
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
break;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
case LROTATE_EXPR:
case NOP_EXPR:
src = ops[0];
if (!is_gimple_val (src))
{
stmt = gimple_build_assign (make_ssa_name (TREE_TYPE (src)),
src);
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
if (!useless_type_conversion_p (dest_type, TREE_TYPE (src)))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
NOP_EXPR, src);
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
inv_op = invert_op (split_store, 2, dest_type, xor_mask);
if (inv_op != NOP_EXPR)
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
inv_op, src, xor_mask);
gimple_set_location (stmt, loc);
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
break;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
default:
src = ops[0];
break;
}
/* If bit insertion is required, we use the source as an accumulator
into which the successive bit-field values are manually inserted.
FIXME: perhaps use BIT_INSERT_EXPR instead in some cases? */
if (group->bit_insertion)
FOR_EACH_VEC_ELT (split_store->orig_stores, k, info)
if (info->rhs_code == BIT_INSERT_EXPR
&& info->bitpos < try_bitpos + try_size
&& info->bitpos + info->bitsize > try_bitpos)
{
/* Mask, truncate, convert to final type, shift and ior into
the accumulator. Note that every step can be a no-op. */
const HOST_WIDE_INT start_gap = info->bitpos - try_bitpos;
const HOST_WIDE_INT end_gap
= (try_bitpos + try_size) - (info->bitpos + info->bitsize);
tree tem = info->ops[0].val;
if (!INTEGRAL_TYPE_P (TREE_TYPE (tem)))
{
const unsigned HOST_WIDE_INT size
= tree_to_uhwi (TYPE_SIZE (TREE_TYPE (tem)));
tree integer_type
= build_nonstandard_integer_type (size, UNSIGNED);
tem = gimple_build (&seq, loc, VIEW_CONVERT_EXPR,
integer_type, tem);
}
if (TYPE_PRECISION (TREE_TYPE (tem)) <= info->bitsize)
{
tree bitfield_type
= build_nonstandard_integer_type (info->bitsize,
UNSIGNED);
tem = gimple_convert (&seq, loc, bitfield_type, tem);
}
else if ((BYTES_BIG_ENDIAN ? start_gap : end_gap) > 0)
{
const unsigned HOST_WIDE_INT imask
= (HOST_WIDE_INT_1U << info->bitsize) - 1;
tem = gimple_build (&seq, loc,
BIT_AND_EXPR, TREE_TYPE (tem), tem,
build_int_cst (TREE_TYPE (tem),
imask));
}
const HOST_WIDE_INT shift
= (BYTES_BIG_ENDIAN ? end_gap : start_gap);
if (shift < 0)
tem = gimple_build (&seq, loc,
RSHIFT_EXPR, TREE_TYPE (tem), tem,
build_int_cst (NULL_TREE, -shift));
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
tem = gimple_convert (&seq, loc, dest_type, tem);
if (shift > 0)
tem = gimple_build (&seq, loc,
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
LSHIFT_EXPR, dest_type, tem,
build_int_cst (NULL_TREE, shift));
src = gimple_build (&seq, loc,
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
BIT_IOR_EXPR, dest_type, tem, src);
}
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
if (!integer_zerop (mask))
{
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
tree tem = make_ssa_name (dest_type);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
tree load_src = unshare_expr (dest);
/* The load might load some or all bits uninitialized,
avoid -W*uninitialized warnings in that case.
As optimization, it would be nice if all the bits are
provably uninitialized (no stores at all yet or previous
store a CLOBBER) we'd optimize away the load and replace
it e.g. with 0. */
middle-end: add support for per-location warning groups. gcc/ChangeLog: * builtins.c (warn_string_no_nul): Replace uses of TREE_NO_WARNING, gimple_no_warning_p and gimple_set_no_warning with warning_suppressed_p, and suppress_warning. (c_strlen): Same. (maybe_warn_for_bound): Same. (warn_for_access): Same. (check_access): Same. (expand_builtin_strncmp): Same. (fold_builtin_varargs): Same. * calls.c (maybe_warn_nonstring_arg): Same. (maybe_warn_rdwr_sizes): Same. * cfgexpand.c (expand_call_stmt): Same. * cgraphunit.c (check_global_declaration): Same. * fold-const.c (fold_undefer_overflow_warnings): Same. (fold_truth_not_expr): Same. (fold_unary_loc): Same. (fold_checksum_tree): Same. * gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Same. (array_bounds_checker::check_mem_ref): Same. (array_bounds_checker::check_addr_expr): Same. (array_bounds_checker::check_array_bounds): Same. * gimple-expr.c (copy_var_decl): Same. * gimple-fold.c (gimple_fold_builtin_strcpy): Same. (gimple_fold_builtin_strncat): Same. (gimple_fold_builtin_stxcpy_chk): Same. (gimple_fold_builtin_stpcpy): Same. (gimple_fold_builtin_sprintf): Same. (fold_stmt_1): Same. * gimple-ssa-isolate-paths.c (diag_returned_locals): Same. * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same. * gimple-ssa-sprintf.c (handle_printf_call): Same. * gimple-ssa-store-merging.c (imm_store_chain_info::output_merged_store): Same. * gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same. * gimple-ssa-warn-restrict.h: Adjust declarations. (maybe_diag_access_bounds): Replace uses of TREE_NO_WARNING, gimple_no_warning_p and gimple_set_no_warning with warning_suppressed_p, and suppress_warning. (check_call): Same. (check_bounds_or_overlap): Same. * gimple.c (gimple_build_call_from_tree): Same. * gimplify.c (gimplify_return_expr): Same. (gimplify_cond_expr): Same. (gimplify_modify_expr_complex_part): Same. (gimplify_modify_expr): Same. (gimple_push_cleanup): Same. (gimplify_expr): Same. * omp-expand.c (expand_omp_for_generic): Same. (expand_omp_taskloop_for_outer): Same. * omp-low.c (lower_rec_input_clauses): Same. (lower_lastprivate_clauses): Same. (lower_send_clauses): Same. (lower_omp_target): Same. * tree-cfg.c (pass_warn_function_return::execute): Same. * tree-complex.c (create_one_component_var): Same. * tree-inline.c (remap_gimple_op_r): Same. (copy_tree_body_r): Same. (declare_return_variable): Same. (expand_call_inline): Same. * tree-nested.c (lookup_field_for_decl): Same. * tree-sra.c (create_access_replacement): Same. (generate_subtree_copies): Same. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same. * tree-ssa-forwprop.c (combine_cond_expr_cond): Same. * tree-ssa-loop-ch.c (ch_base::copy_headers): Same. * tree-ssa-loop-im.c (execute_sm): Same. * tree-ssa-phiopt.c (cond_store_replacement): Same. * tree-ssa-strlen.c (maybe_warn_overflow): Same. (handle_builtin_strcpy): Same. (maybe_diag_stxncpy_trunc): Same. (handle_builtin_stxncpy_strncat): Same. (handle_builtin_strcat): Same. * tree-ssa-uninit.c (get_no_uninit_warning): Same. (set_no_uninit_warning): Same. (uninit_undefined_value_p): Same. (warn_uninit): Same. (maybe_warn_operand): Same. * tree-vrp.c (compare_values_warnv): Same. * vr-values.c (vr_values::extract_range_for_var_from_comparison_expr): Same. (test_for_singularity): Same. * gimple.h (warning_suppressed_p): New function. (suppress_warning): Same. (copy_no_warning): Same. (gimple_set_block): Call gimple_set_location. (gimple_set_location): Call copy_warning.
2021-06-25 03:22:06 +02:00
suppress_warning (load_src, OPT_Wuninitialized);
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
stmt = gimple_build_assign (tem, load_src);
gimple_set_location (stmt, loc);
gimple_set_vuse (stmt, new_vuse);
gimple_seq_add_stmt_without_update (&seq, stmt);
/* FIXME: If there is a single chunk of zero bits in mask,
perhaps use BIT_INSERT_EXPR instead? */
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
BIT_AND_EXPR, tem, mask);
gimple_set_location (stmt, loc);
gimple_seq_add_stmt_without_update (&seq, stmt);
tem = gimple_assign_lhs (stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (TREE_CODE (src) == INTEGER_CST)
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
src = wide_int_to_tree (dest_type,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
wi::bit_and_not (wi::to_wide (src),
wi::to_wide (mask)));
else
{
tree nmask
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
= wide_int_to_tree (dest_type,
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
wi::bit_not (wi::to_wide (mask)));
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
BIT_AND_EXPR, src, nmask);
gimple_set_location (stmt, loc);
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
stmt = gimple_build_assign (make_ssa_name (dest_type),
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
BIT_IOR_EXPR, tem, src);
gimple_set_location (stmt, loc);
gimple_seq_add_stmt_without_update (&seq, stmt);
src = gimple_assign_lhs (stmt);
}
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
stmt = gimple_build_assign (dest, src);
gimple_set_location (stmt, loc);
gimple_set_vuse (stmt, new_vuse);
gimple_seq_add_stmt_without_update (&seq, stmt);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (group->lp_nr && stmt_could_throw_p (cfun, stmt))
add_stmt_to_eh_lp (stmt, group->lp_nr);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
tree new_vdef;
if (i < split_stores.length () - 1)
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
new_vdef = make_ssa_name (gimple_vop (cfun), stmt);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
else
new_vdef = last_vdef;
gimple_set_vdef (stmt, new_vdef);
SSA_NAME_DEF_STMT (new_vdef) = stmt;
new_vuse = new_vdef;
}
FOR_EACH_VEC_ELT (split_stores, i, split_store)
delete split_store;
gcc_assert (seq);
if (dump_file)
{
fprintf (dump_file,
"New sequence of %u stores to replace old one of %u stores\n",
re PR middle-end/22141 (Missing optimization when storing structures) PR middle-end/22141 * gimple-ssa-store-merging.c: Include rtl.h and expr.h. (struct store_immediate_info): Add bitregion_start and bitregion_end fields. (store_immediate_info::store_immediate_info): Add brs and bre arguments and initialize bitregion_{start,end} from those. (struct merged_store_group): Add bitregion_start, bitregion_end, align_base and mask fields. Drop unnecessary struct keyword from struct store_immediate_info. Add do_merge method. (clear_bit_region_be): Use memset instead of loop storing zeros. (merged_store_group::do_merge): New method. (merged_store_group::merge_into): Use do_merge. Allow gaps in between stores as long as the surrounding bitregions have no gaps. (merged_store_group::merge_overlapping): Use do_merge. (merged_store_group::apply_stores): Test that bitregion_{start,end} is byte aligned, rather than requiring that start and width are byte aligned. Drop unnecessary struct keyword from struct store_immediate_info. Allocate and populate also mask array. Make start of the arrays relative to bitregion_start rather than start and size them according to bitregion_{end,start} difference. (struct imm_store_chain_info): Drop unnecessary struct keyword from struct store_immediate_info. (pass_store_merging::gate): Punt if BITS_PER_UNIT or CHAR_BIT is not 8. (pass_store_merging::terminate_all_aliasing_chains): Drop unnecessary struct keyword from struct store_immediate_info. (imm_store_chain_info::coalesce_immediate_stores): Allow gaps in between stores as long as the surrounding bitregions have no gaps. Formatting fixes. (struct split_store): Add orig non-static data member. (split_store::split_store): Initialize orig to false. (find_constituent_stmts): Return store_immediate_info *, non-NULL if there is exactly a single original stmt. Change stmts argument to pointer from reference, if NULL, don't push anything to it. Add first argument, use it to optimize skipping over orig stmts that are known to be before bitpos already. Simplify. (split_group): Return unsigned int count how many stores are or would be needed rather than a bool. Add allow_unaligned argument. Change split_stores argument from reference to pointer, if NULL, only do a dry run computing how many stores would be produced. Rewritten algorithm to use both alignment and misalign if !allow_unaligned and handle bitfield stores with gaps. (imm_store_chain_info::output_merged_store): Set start_byte_pos from bitregion_start instead of start. Compute allow_unaligned here, if true, do 2 split_group dry runs to compute which one produces fewer stores and prefer aligned if equal. Punt if new count is bigger or equal than original before emitting any statements, rather than during that. Remove no longer needed new_ssa_names tracking. Replace num_stmts with split_stores.length (). Use 32-bit stack allocated entries in split_stores auto_vec. Try to reuse original store lhs/rhs1 if possible. Handle bitfields with gaps. (pass_store_merging::execute): Ignore bitsize == 0 stores. Compute bitregion_{start,end} for the stores and construct store_immediate_info with that. Formatting fixes. * gcc.dg/store_merging_10.c: New test. * gcc.dg/store_merging_11.c: New test. * gcc.dg/store_merging_12.c: New test. * g++.dg/pr71694.C: Add -fno-store-merging to dg-options. From-SVN: r254213
2017-10-30 12:04:49 +01:00
split_stores.length (), orig_num_stmts);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (dump_flags & TDF_DETAILS)
print_gimple_seq (dump_file, seq, 0, TDF_VOPS | TDF_MEMSYMS);
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (gimple_clobber_p (group->last_stmt))
update_stmt (group->last_stmt);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (group->lp_nr > 0)
{
/* We're going to insert a sequence of (potentially) throwing stores
into an active EH region. This means that we're going to create
new basic blocks with EH edges pointing to the post landing pad
and, therefore, to have to update its PHI nodes, if any. For the
virtual PHI node, we're going to use the VDEFs created above, but
for the other nodes, we need to record the original reaching defs. */
eh_landing_pad lp = get_eh_landing_pad_from_number (group->lp_nr);
basic_block lp_bb = label_to_block (cfun, lp->post_landing_pad);
basic_block last_bb = gimple_bb (group->last_stmt);
edge last_edge = find_edge (last_bb, lp_bb);
auto_vec<tree, 16> last_defs;
gphi_iterator gpi;
for (gpi = gsi_start_phis (lp_bb); !gsi_end_p (gpi); gsi_next (&gpi))
{
gphi *phi = gpi.phi ();
tree last_def;
if (virtual_operand_p (gimple_phi_result (phi)))
last_def = NULL_TREE;
else
last_def = gimple_phi_arg_def (phi, last_edge->dest_idx);
last_defs.safe_push (last_def);
}
/* Do the insertion. Then, if new basic blocks have been created in the
process, rewind the chain of VDEFs create above to walk the new basic
blocks and update the corresponding arguments of the PHI nodes. */
update_modified_stmts (seq);
if (gimple_find_sub_bbs (seq, &last_gsi))
while (last_vdef != gimple_vuse (group->last_stmt))
{
gimple *stmt = SSA_NAME_DEF_STMT (last_vdef);
if (stmt_could_throw_p (cfun, stmt))
{
edge new_edge = find_edge (gimple_bb (stmt), lp_bb);
unsigned int i;
for (gpi = gsi_start_phis (lp_bb), i = 0;
!gsi_end_p (gpi);
gsi_next (&gpi), i++)
{
gphi *phi = gpi.phi ();
tree new_def;
if (virtual_operand_p (gimple_phi_result (phi)))
new_def = last_vdef;
else
new_def = last_defs[i];
add_phi_arg (phi, new_def, new_edge, UNKNOWN_LOCATION);
}
}
last_vdef = gimple_vuse (stmt);
}
}
else
gsi_insert_seq_after (&last_gsi, seq, GSI_SAME_STMT);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
for (int j = 0; j < 2; ++j)
if (load_seq[j])
gsi_insert_seq_after (&load_gsi[j], load_seq[j], GSI_SAME_STMT);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return true;
}
/* Process the merged_store_group objects created in the coalescing phase.
The stores are all against the base object BASE.
Try to output the widened stores and delete the original statements if
successful. Return true iff any changes were made. */
bool
imm_store_chain_info::output_merged_stores ()
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
unsigned int i;
merged_store_group *merged_store;
bool ret = false;
FOR_EACH_VEC_ELT (m_merged_store_groups, i, merged_store)
{
if (dbg_cnt (store_merging)
&& output_merged_store (merged_store))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
unsigned int j;
store_immediate_info *store;
FOR_EACH_VEC_ELT (merged_store->stores, j, store)
{
gimple *stmt = store->stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
/* Don't remove clobbers, they are still useful even if
everything is overwritten afterwards. */
if (gimple_clobber_p (stmt))
continue;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gsi_remove (&gsi, true);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (store->lp_nr)
remove_stmt_from_eh_lp (stmt);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (stmt != merged_store->last_stmt)
{
unlink_stmt_vdef (stmt);
release_defs (stmt);
}
}
ret = true;
}
}
if (ret && dump_file)
fprintf (dump_file, "Merging successful!\n");
return ret;
}
/* Coalesce the store_immediate_info objects recorded against the base object
BASE in the first phase and output them.
Delete the allocated structures.
Return true if any changes were made. */
bool
imm_store_chain_info::terminate_and_process_chain ()
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Terminating chain with %u stores\n",
m_store_info.length ());
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Process store chain. */
bool ret = false;
if (m_store_info.length () > 1)
{
ret = coalesce_immediate_stores ();
if (ret)
ret = output_merged_stores ();
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Delete all the entries we allocated ourselves. */
store_immediate_info *info;
unsigned int i;
FOR_EACH_VEC_ELT (m_store_info, i, info)
delete info;
merged_store_group *merged_info;
FOR_EACH_VEC_ELT (m_merged_store_groups, i, merged_info)
delete merged_info;
return ret;
}
/* Return true iff LHS is a destination potentially interesting for
store merging. In practice these are the codes that get_inner_reference
can process. */
static bool
lhs_valid_for_store_merging_p (tree lhs)
{
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (DECL_P (lhs))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return true;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
switch (TREE_CODE (lhs))
{
case ARRAY_REF:
case ARRAY_RANGE_REF:
case BIT_FIELD_REF:
case COMPONENT_REF:
case MEM_REF:
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
case VIEW_CONVERT_EXPR:
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
return true;
default:
return false;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
/* Return true if the tree RHS is a constant we want to consider
during store merging. In practice accept all codes that
native_encode_expr accepts. */
static bool
rhs_valid_for_store_merging_p (tree rhs)
{
poly_int: GET_MODE_SIZE This patch changes GET_MODE_SIZE from unsigned short to poly_uint16. The non-mechanical parts were handled by previous patches. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (mode_size): Change from unsigned short to poly_uint16_pod. (mode_to_bytes): Return a poly_uint16 rather than an unsigned short. (GET_MODE_SIZE): Return a constant if ONLY_FIXED_SIZE_MODES, or if measurement_type is not polynomial. (fixed_size_mode::includes_p): Check for constant-sized modes. * genmodes.c (emit_mode_size_inline): Make mode_size_inline return a poly_uint16 rather than an unsigned short. (emit_mode_size): Change the type of mode_size from unsigned short to poly_uint16_pod. Use ZERO_COEFFS for the initializer. (emit_mode_adjustments): Cope with polynomial vector sizes. * lto-streamer-in.c (lto_input_mode_table): Use bp_unpack_poly_value for GET_MODE_SIZE. * lto-streamer-out.c (lto_write_mode_table): Use bp_pack_poly_value for GET_MODE_SIZE. * auto-inc-dec.c (try_merge): Treat GET_MODE_SIZE as polynomial. * builtins.c (expand_ifn_atomic_compare_exchange_into_call): Likewise. * caller-save.c (setup_save_areas): Likewise. (replace_reg_with_saved_mem): Likewise. * calls.c (emit_library_call_value_1): Likewise. * combine-stack-adj.c (combine_stack_adjustments_for_block): Likewise. * combine.c (simplify_set, make_extraction, simplify_shift_const_1) (gen_lowpart_for_combine): Likewise. * convert.c (convert_to_integer_1): Likewise. * cse.c (equiv_constant, cse_insn): Likewise. * cselib.c (autoinc_split, cselib_hash_rtx): Likewise. (cselib_subst_to_values): Likewise. * dce.c (word_dce_process_block): Likewise. * df-problems.c (df_word_lr_mark_ref): Likewise. * dwarf2cfi.c (init_one_dwarf_reg_size): Likewise. * dwarf2out.c (multiple_reg_loc_descriptor, mem_loc_descriptor) (concat_loc_descriptor, concatn_loc_descriptor, loc_descriptor) (rtl_for_decl_location): Likewise. * emit-rtl.c (gen_highpart, widen_memory_access): Likewise. * expmed.c (extract_bit_field_1, extract_integral_bit_field): Likewise. * expr.c (emit_group_load_1, clear_storage_hints): Likewise. (emit_move_complex, emit_move_multi_word, emit_push_insn): Likewise. (expand_expr_real_1): Likewise. * function.c (assign_parm_setup_block_p, assign_parm_setup_block) (pad_below): Likewise. * gimple-fold.c (optimize_atomic_compare_exchange_p): Likewise. * gimple-ssa-store-merging.c (rhs_valid_for_store_merging_p): Likewise. * ira.c (get_subreg_tracking_sizes): Likewise. * ira-build.c (ira_create_allocno_objects): Likewise. * ira-color.c (coalesced_pseudo_reg_slot_compare): Likewise. (ira_sort_regnos_for_alter_reg): Likewise. * ira-costs.c (record_operand_costs): Likewise. * lower-subreg.c (interesting_mode_p, simplify_gen_subreg_concatn) (resolve_simple_move): Likewise. * lra-constraints.c (get_reload_reg, operands_match_p): Likewise. (process_addr_reg, simplify_operand_subreg, curr_insn_transform) (lra_constraints): Likewise. (CONST_POOL_OK_P): Reject variable-sized modes. * lra-spills.c (slot, assign_mem_slot, pseudo_reg_slot_compare) (add_pseudo_to_slot, lra_spill): Likewise. * omp-low.c (omp_clause_aligned_alignment): Likewise. * optabs-query.c (get_best_extraction_insn): Likewise. * optabs-tree.c (expand_vec_cond_expr_p): Likewise. * optabs.c (expand_vec_perm_var, expand_vec_cond_expr): Likewise. (expand_mult_highpart, valid_multiword_target_p): Likewise. * recog.c (offsettable_address_addr_space_p): Likewise. * regcprop.c (maybe_mode_change): Likewise. * reginfo.c (choose_hard_reg_mode, record_subregs_of_mode): Likewise. * regrename.c (build_def_use): Likewise. * regstat.c (dump_reg_info): Likewise. * reload.c (complex_word_subreg_p, push_reload, find_dummy_reload) (find_reloads, find_reloads_subreg_address): Likewise. * reload1.c (eliminate_regs_1): Likewise. * rtlanal.c (for_each_inc_dec_find_inc_dec, rtx_cost): Likewise. * simplify-rtx.c (avoid_constant_pool_reference): Likewise. (simplify_binary_operation_1, simplify_subreg): Likewise. * targhooks.c (default_function_arg_padding): Likewise. (default_hard_regno_nregs, default_class_max_nregs): Likewise. * tree-cfg.c (verify_gimple_assign_binary): Likewise. (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-ssa-loop-ivopts.c (add_autoinc_candidates): Likewise. (get_address_cost_ainc): Likewise. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise. (vect_supportable_dr_alignment): Likewise. * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. (vectorizable_reduction): Likewise. * tree-vect-stmts.c (vectorizable_assignment, vectorizable_shift) (vectorizable_operation, vectorizable_load): Likewise. * tree.c (build_same_sized_truth_vector_type): Likewise. * valtrack.c (cleanup_auto_inc_dec): Likewise. * var-tracking.c (emit_note_insn_var_location): Likewise. * config/arc/arc.h (ASM_OUTPUT_CASE_END): Use as_a <scalar_int_mode>. (ADDR_VEC_ALIGN): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256201
2018-01-03 22:42:52 +01:00
unsigned HOST_WIDE_INT size;
if (TREE_CODE (rhs) == CONSTRUCTOR
&& CONSTRUCTOR_NELTS (rhs) == 0
&& TYPE_SIZE_UNIT (TREE_TYPE (rhs))
&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (rhs))))
return true;
poly_int: GET_MODE_SIZE This patch changes GET_MODE_SIZE from unsigned short to poly_uint16. The non-mechanical parts were handled by previous patches. 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (mode_size): Change from unsigned short to poly_uint16_pod. (mode_to_bytes): Return a poly_uint16 rather than an unsigned short. (GET_MODE_SIZE): Return a constant if ONLY_FIXED_SIZE_MODES, or if measurement_type is not polynomial. (fixed_size_mode::includes_p): Check for constant-sized modes. * genmodes.c (emit_mode_size_inline): Make mode_size_inline return a poly_uint16 rather than an unsigned short. (emit_mode_size): Change the type of mode_size from unsigned short to poly_uint16_pod. Use ZERO_COEFFS for the initializer. (emit_mode_adjustments): Cope with polynomial vector sizes. * lto-streamer-in.c (lto_input_mode_table): Use bp_unpack_poly_value for GET_MODE_SIZE. * lto-streamer-out.c (lto_write_mode_table): Use bp_pack_poly_value for GET_MODE_SIZE. * auto-inc-dec.c (try_merge): Treat GET_MODE_SIZE as polynomial. * builtins.c (expand_ifn_atomic_compare_exchange_into_call): Likewise. * caller-save.c (setup_save_areas): Likewise. (replace_reg_with_saved_mem): Likewise. * calls.c (emit_library_call_value_1): Likewise. * combine-stack-adj.c (combine_stack_adjustments_for_block): Likewise. * combine.c (simplify_set, make_extraction, simplify_shift_const_1) (gen_lowpart_for_combine): Likewise. * convert.c (convert_to_integer_1): Likewise. * cse.c (equiv_constant, cse_insn): Likewise. * cselib.c (autoinc_split, cselib_hash_rtx): Likewise. (cselib_subst_to_values): Likewise. * dce.c (word_dce_process_block): Likewise. * df-problems.c (df_word_lr_mark_ref): Likewise. * dwarf2cfi.c (init_one_dwarf_reg_size): Likewise. * dwarf2out.c (multiple_reg_loc_descriptor, mem_loc_descriptor) (concat_loc_descriptor, concatn_loc_descriptor, loc_descriptor) (rtl_for_decl_location): Likewise. * emit-rtl.c (gen_highpart, widen_memory_access): Likewise. * expmed.c (extract_bit_field_1, extract_integral_bit_field): Likewise. * expr.c (emit_group_load_1, clear_storage_hints): Likewise. (emit_move_complex, emit_move_multi_word, emit_push_insn): Likewise. (expand_expr_real_1): Likewise. * function.c (assign_parm_setup_block_p, assign_parm_setup_block) (pad_below): Likewise. * gimple-fold.c (optimize_atomic_compare_exchange_p): Likewise. * gimple-ssa-store-merging.c (rhs_valid_for_store_merging_p): Likewise. * ira.c (get_subreg_tracking_sizes): Likewise. * ira-build.c (ira_create_allocno_objects): Likewise. * ira-color.c (coalesced_pseudo_reg_slot_compare): Likewise. (ira_sort_regnos_for_alter_reg): Likewise. * ira-costs.c (record_operand_costs): Likewise. * lower-subreg.c (interesting_mode_p, simplify_gen_subreg_concatn) (resolve_simple_move): Likewise. * lra-constraints.c (get_reload_reg, operands_match_p): Likewise. (process_addr_reg, simplify_operand_subreg, curr_insn_transform) (lra_constraints): Likewise. (CONST_POOL_OK_P): Reject variable-sized modes. * lra-spills.c (slot, assign_mem_slot, pseudo_reg_slot_compare) (add_pseudo_to_slot, lra_spill): Likewise. * omp-low.c (omp_clause_aligned_alignment): Likewise. * optabs-query.c (get_best_extraction_insn): Likewise. * optabs-tree.c (expand_vec_cond_expr_p): Likewise. * optabs.c (expand_vec_perm_var, expand_vec_cond_expr): Likewise. (expand_mult_highpart, valid_multiword_target_p): Likewise. * recog.c (offsettable_address_addr_space_p): Likewise. * regcprop.c (maybe_mode_change): Likewise. * reginfo.c (choose_hard_reg_mode, record_subregs_of_mode): Likewise. * regrename.c (build_def_use): Likewise. * regstat.c (dump_reg_info): Likewise. * reload.c (complex_word_subreg_p, push_reload, find_dummy_reload) (find_reloads, find_reloads_subreg_address): Likewise. * reload1.c (eliminate_regs_1): Likewise. * rtlanal.c (for_each_inc_dec_find_inc_dec, rtx_cost): Likewise. * simplify-rtx.c (avoid_constant_pool_reference): Likewise. (simplify_binary_operation_1, simplify_subreg): Likewise. * targhooks.c (default_function_arg_padding): Likewise. (default_hard_regno_nregs, default_class_max_nregs): Likewise. * tree-cfg.c (verify_gimple_assign_binary): Likewise. (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-ssa-loop-ivopts.c (add_autoinc_candidates): Likewise. (get_address_cost_ainc): Likewise. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise. (vect_supportable_dr_alignment): Likewise. * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. (vectorizable_reduction): Likewise. * tree-vect-stmts.c (vectorizable_assignment, vectorizable_shift) (vectorizable_operation, vectorizable_load): Likewise. * tree.c (build_same_sized_truth_vector_type): Likewise. * valtrack.c (cleanup_auto_inc_dec): Likewise. * var-tracking.c (emit_note_insn_var_location): Likewise. * config/arc/arc.h (ASM_OUTPUT_CASE_END): Use as_a <scalar_int_mode>. (ADDR_VEC_ALIGN): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256201
2018-01-03 22:42:52 +01:00
return (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (rhs))).is_constant (&size)
&& native_encode_expr (rhs, NULL, size) != 0);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
/* Adjust *PBITPOS, *PBITREGION_START and *PBITREGION_END by BYTE_OFF bytes
and return true on success or false on failure. */
static bool
adjust_bit_pos (poly_offset_int byte_off,
poly_int64 *pbitpos,
poly_uint64 *pbitregion_start,
poly_uint64 *pbitregion_end)
{
poly_offset_int bit_off = byte_off << LOG2_BITS_PER_UNIT;
bit_off += *pbitpos;
if (known_ge (bit_off, 0) && bit_off.to_shwi (pbitpos))
{
if (maybe_ne (*pbitregion_end, 0U))
{
bit_off = byte_off << LOG2_BITS_PER_UNIT;
bit_off += *pbitregion_start;
if (bit_off.to_uhwi (pbitregion_start))
{
bit_off = byte_off << LOG2_BITS_PER_UNIT;
bit_off += *pbitregion_end;
if (!bit_off.to_uhwi (pbitregion_end))
*pbitregion_end = 0;
}
else
*pbitregion_end = 0;
}
return true;
}
else
return false;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* If MEM is a memory reference usable for store merging (either as
store destination or for loads), return the non-NULL base_addr
and set *PBITSIZE, *PBITPOS, *PBITREGION_START and *PBITREGION_END.
Otherwise return NULL, *PBITPOS should be still valid even for that
case. */
static tree
mem_valid_for_store_merging (tree mem, poly_uint64 *pbitsize,
poly_uint64 *pbitpos,
poly_uint64 *pbitregion_start,
poly_uint64 *pbitregion_end)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
poly_int64 bitsize, bitpos;
poly_uint64 bitregion_start = 0, bitregion_end = 0;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
machine_mode mode;
int unsignedp = 0, reversep = 0, volatilep = 0;
tree offset;
tree base_addr = get_inner_reference (mem, &bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
*pbitsize = bitsize;
if (known_le (bitsize, 0))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return NULL_TREE;
if (TREE_CODE (mem) == COMPONENT_REF
&& DECL_BIT_FIELD_TYPE (TREE_OPERAND (mem, 1)))
{
get_bit_range (&bitregion_start, &bitregion_end, mem, &bitpos, &offset);
if (maybe_ne (bitregion_end, 0U))
bitregion_end += 1;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
if (reversep)
return NULL_TREE;
/* We do not want to rewrite TARGET_MEM_REFs. */
if (TREE_CODE (base_addr) == TARGET_MEM_REF)
return NULL_TREE;
/* In some cases get_inner_reference may return a
MEM_REF [ptr + byteoffset]. For the purposes of this pass
canonicalize the base_addr to MEM_REF [ptr] and take
byteoffset into account in the bitpos. This occurs in
PR 23684 and this way we can catch more chains. */
else if (TREE_CODE (base_addr) == MEM_REF)
{
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (!adjust_bit_pos (mem_ref_offset (base_addr), &bitpos,
&bitregion_start, &bitregion_end))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return NULL_TREE;
base_addr = TREE_OPERAND (base_addr, 0);
}
/* get_inner_reference returns the base object, get at its
address now. */
else
{
if (maybe_lt (bitpos, 0))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return NULL_TREE;
base_addr = build_fold_addr_expr (base_addr);
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (offset)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
/* If the access is variable offset then a base decl has to be
address-taken to be able to emit pointer-based stores to it.
??? We might be able to get away with re-using the original
base up to the first variable part and then wrapping that inside
a BIT_FIELD_REF. */
tree base = get_base_address (base_addr);
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (!base || (DECL_P (base) && !TREE_ADDRESSABLE (base)))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return NULL_TREE;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
/* Similarly to above for the base, remove constant from the offset. */
if (TREE_CODE (offset) == PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (offset, 1)) == INTEGER_CST
&& adjust_bit_pos (wi::to_poly_offset (TREE_OPERAND (offset, 1)),
&bitpos, &bitregion_start, &bitregion_end))
offset = TREE_OPERAND (offset, 0);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
base_addr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (base_addr),
base_addr, offset);
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (known_eq (bitregion_end, 0U))
{
bitregion_start = round_down_to_byte_boundary (bitpos);
bitregion_end = round_up_to_byte_boundary (bitpos + bitsize);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
*pbitsize = bitsize;
*pbitpos = bitpos;
*pbitregion_start = bitregion_start;
*pbitregion_end = bitregion_end;
return base_addr;
}
/* Return true if STMT is a load that can be used for store merging.
In that case fill in *OP. BITSIZE, BITPOS, BITREGION_START and
BITREGION_END are properties of the corresponding store. */
static bool
handled_load (gimple *stmt, store_operand_info *op,
poly_uint64 bitsize, poly_uint64 bitpos,
poly_uint64 bitregion_start, poly_uint64 bitregion_end)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
if (!is_gimple_assign (stmt))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return false;
if (gimple_assign_rhs_code (stmt) == BIT_NOT_EXPR)
{
tree rhs1 = gimple_assign_rhs1 (stmt);
if (TREE_CODE (rhs1) == SSA_NAME
&& handled_load (SSA_NAME_DEF_STMT (rhs1), op, bitsize, bitpos,
bitregion_start, bitregion_end))
{
/* Don't allow _1 = load; _2 = ~1; _3 = ~_2; which should have
been optimized earlier, but if allowed here, would confuse the
multiple uses counting. */
if (op->bit_not_p)
return false;
op->bit_not_p = !op->bit_not_p;
return true;
}
return false;
}
if (gimple_vuse (stmt)
&& gimple_assign_load_p (stmt)
Add a fun parameter to three stmt_could_throw... functions This long patch only does one simple thing, adds an explicit function parameter to predicates stmt_could_throw_p, stmt_can_throw_external and stmt_can_throw_internal. My motivation was ability to use stmt_can_throw_external in IPA analysis phase without the need to push cfun. As I have discovered, we were already doing that in cgraph.c, which this patch avoids as well. In the process, I had to add a struct function parameter to stmt_could_throw_p and decided to also change the interface of stmt_can_throw_internal just for the sake of some minimal consistency. In the process I have discovered that calling method cgraph_node::create_version_clone_with_body (used by ipa-split, ipa-sra, OMP simd and multiple_target) leads to calls of stmt_can_throw_external with NULL cfun. I have worked around this by making stmt_can_throw_external and stmt_could_throw_p gracefully accept NULL and just be pessimistic in that case. The problem with fixing this in a better way is that struct function for the clone is created after cloning edges where we attempt to push the yet not existing cfun, and moving it before would require a bit of surgery in tree-inline.c. A slightly hackish but simpler fix might be to explicitely pass the "old" function to symbol_table::create_edge because it should be just as good at that moment. In any event, that is a topic for another patch. I believe that currently we incorrectly use cfun in maybe_clean_eh_stmt_fn and maybe_duplicate_eh_stmt_fn, both in tree-eh.c, and so I have fixed these cases too. The bulk of other changes is just mechanical adding of cfun to all users. Bootstrapped and tested on x86_64-linux (also with extra NULLing and restoring cfun to double check it is not used in a place I missed), OK for trunk? Thanks, Martin 2018-10-22 Martin Jambor <mjambor@suse.cz> * tree-eh.h (stmt_could_throw_p): Add function parameter. (stmt_can_throw_external): Likewise. (stmt_can_throw_internal): Likewise. * tree-eh.c (lower_eh_constructs_2): Pass cfun to stmt_could_throw_p. (lower_eh_constructs_2): Likewise. (stmt_could_throw_p): Add fun parameter, use it instead of cfun. (stmt_can_throw_external): Likewise. (stmt_can_throw_internal): Likewise. (maybe_clean_eh_stmt_fn): Pass cfun to stmt_could_throw_p. (maybe_clean_or_replace_eh_stmt): Pass cfun to stmt_could_throw_p. (maybe_duplicate_eh_stmt_fn): Pass new_fun to stmt_could_throw_p. (maybe_duplicate_eh_stmt): Pass cfun to stmt_could_throw_p. (pass_lower_eh_dispatch::execute): Pass cfun to stmt_can_throw_external. (cleanup_empty_eh): Likewise. (verify_eh_edges): Pass cfun to stmt_could_throw_p. * cgraph.c (cgraph_edge::set_call_stmt): Pass a function to stmt_can_throw_external instead of pushing it to cfun. (symbol_table::create_edge): Likewise. * gimple-fold.c (fold_builtin_atomic_compare_exchange): Pass cfun to stmt_can_throw_internal. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Pass cfun to stmt_could_throw_p. * gimple-ssa-store-merging.c (handled_load): Pass cfun to stmt_can_throw_internal. (pass_store_merging::execute): Likewise. * gimple-ssa-strength-reduction.c (find_candidates_dom_walker::before_dom_children): Pass cfun to stmt_could_throw_p. * gimplify-me.c (gimple_regimplify_operands): Pass cfun to stmt_can_throw_internal. * ipa-pure-const.c (check_call): Pass cfun to stmt_could_throw_p and to stmt_can_throw_external. (check_stmt): Pass cfun to stmt_could_throw_p. (check_stmt): Pass cfun to stmt_can_throw_external. (pass_nothrow::execute): Likewise. * trans-mem.c (expand_call_tm): Pass cfun to stmt_can_throw_internal. * tree-cfg.c (is_ctrl_altering_stmt): Pass cfun to stmt_can_throw_internal. (verify_gimple_in_cfg): Pass cfun to stmt_could_throw_p. (stmt_can_terminate_bb_p): Pass cfun to stmt_can_throw_external. (gimple_purge_dead_eh_edges): Pass cfun to stmt_can_throw_internal. * tree-complex.c (expand_complex_libcall): Pass cfun to stmt_could_throw_p and to stmt_can_throw_internal. (expand_complex_multiplication): Pass cfun to stmt_can_throw_internal. * tree-inline.c (copy_edges_for_bb): Likewise. (maybe_move_debug_stmts_to_successors): Likewise. * tree-outof-ssa.c (ssa_is_replaceable_p): Pass cfun to stmt_could_throw_p. * tree-parloops.c (oacc_entry_exit_ok_1): Likewise. * tree-sra.c (scan_function): Pass cfun to stmt_can_throw_external. * tree-ssa-alias.c (stmt_kills_ref_p): Pass cfun to stmt_can_throw_internal. * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Pass cfun to stmt_could_throw_p. (mark_aliased_reaching_defs_necessary_1): Pass cfun to stmt_can_throw_internal. * tree-ssa-forwprop.c (pass_forwprop::execute): Likewise. * tree-ssa-loop-im.c (movement_possibility): Pass cfun to stmt_could_throw_p. * tree-ssa-loop-ivopts.c (find_givs_in_stmt_scev): Likewise. (add_autoinc_candidates): Pass cfun to stmt_can_throw_internal. * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise. (convert_mult_to_fma_1): Likewise. (convert_to_divmod): Likewise. * tree-ssa-phiprop.c (propagate_with_phi): Likewise. * tree-ssa-pre.c (compute_avail): Pass cfun to stmt_could_throw_p. * tree-ssa-propagate.c (substitute_and_fold_dom_walker::before_dom_children): Likewise. * tree-ssa-reassoc.c (suitable_cond_bb): Likewise. (maybe_optimize_range_tests): Likewise. (linearize_expr_tree): Likewise. (reassociate_bb): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_call): Likewise. * tree-ssa-scopedtables.c (hashable_expr_equal_p): Likewise. * tree-ssa-strlen.c (adjust_last_stmt): Likewise. (handle_char_store): Likewise. * tree-vect-data-refs.c (vect_find_stmt_data_reference): Pass cfun to stmt_can_throw_internal. * tree-vect-patterns.c (check_bool_pattern): Pass cfun to stmt_could_throw_p. * tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise. (vectorizable_call): Pass cfun to stmt_can_throw_internal. (vectorizable_simd_clone_call): Likewise. * value-prof.c (gimple_ic): Pass cfun to stmt_could_throw_p. (gimple_stringop_fixed_value): Likewise. From-SVN: r265372
2018-10-22 10:27:50 +02:00
&& !stmt_can_throw_internal (cfun, stmt)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
&& !gimple_has_volatile_ops (stmt))
{
tree mem = gimple_assign_rhs1 (stmt);
op->base_addr
= mem_valid_for_store_merging (mem, &op->bitsize, &op->bitpos,
&op->bitregion_start,
&op->bitregion_end);
if (op->base_addr != NULL_TREE
&& known_eq (op->bitsize, bitsize)
&& multiple_p (op->bitpos - bitpos, BITS_PER_UNIT)
&& known_ge (op->bitpos - op->bitregion_start,
bitpos - bitregion_start)
&& known_ge (op->bitregion_end - op->bitpos,
bitregion_end - bitpos))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
op->stmt = stmt;
op->val = mem;
op->bit_not_p = false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
return true;
}
}
return false;
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
/* Return the index number of the landing pad for STMT, if any. */
static int
lp_nr_for_store (gimple *stmt)
{
if (!cfun->can_throw_non_call_exceptions || !cfun->eh)
return 0;
if (!stmt_could_throw_p (cfun, stmt))
return 0;
return lookup_stmt_eh_lp (stmt);
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* Record the store STMT for store merging optimization if it can be
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
optimized. Return true if any changes were made. */
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bool
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
pass_store_merging::process_store (gimple *stmt)
{
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
poly_uint64 bitsize, bitpos = 0;
poly_uint64 bitregion_start = 0, bitregion_end = 0;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree base_addr
= mem_valid_for_store_merging (lhs, &bitsize, &bitpos,
&bitregion_start, &bitregion_end);
if (known_eq (bitsize, 0U))
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
return false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
bool invalid = (base_addr == NULL_TREE
|| (maybe_gt (bitsize,
(unsigned int) MAX_BITSIZE_MODE_ANY_INT)
&& TREE_CODE (rhs) != INTEGER_CST
&& (TREE_CODE (rhs) != CONSTRUCTOR
|| CONSTRUCTOR_NELTS (rhs) != 0)));
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
enum tree_code rhs_code = ERROR_MARK;
bool bit_not_p = false;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
struct symbolic_number n;
gimple *ins_stmt = NULL;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_operand_info ops[2];
if (invalid)
;
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
else if (TREE_CODE (rhs) == STRING_CST)
{
rhs_code = STRING_CST;
ops[0].val = rhs;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
else if (rhs_valid_for_store_merging_p (rhs))
{
rhs_code = INTEGER_CST;
ops[0].val = rhs;
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
else if (TREE_CODE (rhs) == SSA_NAME)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
gimple *def_stmt = SSA_NAME_DEF_STMT (rhs), *def_stmt1, *def_stmt2;
if (!is_gimple_assign (def_stmt))
invalid = true;
else if (handled_load (def_stmt, &ops[0], bitsize, bitpos,
bitregion_start, bitregion_end))
rhs_code = MEM_REF;
else if (gimple_assign_rhs_code (def_stmt) == BIT_NOT_EXPR)
{
tree rhs1 = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (rhs1) == SSA_NAME
&& is_gimple_assign (SSA_NAME_DEF_STMT (rhs1)))
{
bit_not_p = true;
def_stmt = SSA_NAME_DEF_STMT (rhs1);
}
}
if (rhs_code == ERROR_MARK && !invalid)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
switch ((rhs_code = gimple_assign_rhs_code (def_stmt)))
{
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
tree rhs1, rhs2;
rhs1 = gimple_assign_rhs1 (def_stmt);
rhs2 = gimple_assign_rhs2 (def_stmt);
invalid = true;
if (TREE_CODE (rhs1) != SSA_NAME)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
break;
def_stmt1 = SSA_NAME_DEF_STMT (rhs1);
if (!is_gimple_assign (def_stmt1)
|| !handled_load (def_stmt1, &ops[0], bitsize, bitpos,
bitregion_start, bitregion_end))
break;
if (rhs_valid_for_store_merging_p (rhs2))
ops[1].val = rhs2;
else if (TREE_CODE (rhs2) != SSA_NAME)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
break;
else
{
def_stmt2 = SSA_NAME_DEF_STMT (rhs2);
if (!is_gimple_assign (def_stmt2))
break;
else if (!handled_load (def_stmt2, &ops[1], bitsize, bitpos,
bitregion_start, bitregion_end))
break;
}
invalid = false;
break;
default:
invalid = true;
break;
}
unsigned HOST_WIDE_INT const_bitsize;
if (bitsize.is_constant (&const_bitsize)
&& (const_bitsize % BITS_PER_UNIT) == 0
&& const_bitsize <= 64
&& multiple_p (bitpos, BITS_PER_UNIT))
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
{
ins_stmt = find_bswap_or_nop_1 (def_stmt, &n, 12);
if (ins_stmt)
{
uint64_t nn = n.n;
for (unsigned HOST_WIDE_INT i = 0;
i < const_bitsize;
i += BITS_PER_UNIT, nn >>= BITS_PER_MARKER)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if ((nn & MARKER_MASK) == 0
|| (nn & MARKER_MASK) == MARKER_BYTE_UNKNOWN)
{
ins_stmt = NULL;
break;
}
if (ins_stmt)
{
if (invalid)
{
rhs_code = LROTATE_EXPR;
ops[0].base_addr = NULL_TREE;
ops[1].base_addr = NULL_TREE;
}
invalid = false;
}
}
}
if (invalid
&& bitsize.is_constant (&const_bitsize)
&& ((const_bitsize % BITS_PER_UNIT) != 0
|| !multiple_p (bitpos, BITS_PER_UNIT))
&& const_bitsize <= MAX_FIXED_MODE_SIZE)
{
/* Bypass a conversion to the bit-field type. */
if (!bit_not_p
&& is_gimple_assign (def_stmt)
&& CONVERT_EXPR_CODE_P (rhs_code))
{
tree rhs1 = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (rhs1) == SSA_NAME
&& INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
rhs = rhs1;
}
rhs_code = BIT_INSERT_EXPR;
bit_not_p = false;
ops[0].val = rhs;
ops[0].base_addr = NULL_TREE;
ops[1].base_addr = NULL_TREE;
invalid = false;
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
Extend store merging to STRING_CST The GIMPLE store merging pass doesn't merge STRING_CSTs in the general case, although they are accepted by native_encode_expr; the reason is that the pass only works with integral modes, i.e. with chunks whose size is a power of two. There are two possible ways of extending it to handle STRING_CSTs: 1) lift the condition of integral modes and treat STRING_CSTs as other _CST nodes but with arbitrary size; 2) implement a specific and separate handling for STRING_CSTs. The attached patch implements 2) for the following reasons: on the one hand, even in Ada where character strings are first-class citizens, cases where merging STRING_CSTs with other *_CST nodes would be possible are quite rare in practice; on the other hand, string concatenations happen more naturally and frequently thanks to the "&" operator, giving rise to merging opportunities. gcc/ChangeLog: * gimple-fold.c (gimple_fold_builtin_memory_op): Fold calls that were initially created for the assignment of a variable-sized object and whose source is now a string constant. * gimple-ssa-store-merging.c (struct merged_store_group): Document STRING_CST for rhs_code field. Add string_concatenation boolean field. (merged_store_group::merged_store_group): Initialize it as well as bit_insertion here. (merged_store_group::do_merge): Set it upon seeing a STRING_CST. Also set bit_insertion here upon seeing a BIT_INSERT_EXPR. (merged_store_group::apply_stores): Clear it for small regions. Do not create a power-of-2-sized buffer if it is still true. And do not set bit_insertion here again. (encode_tree_to_bitpos): Deal with BLKmode for the expression. (merged_store_group::can_be_merged_into): Deal with STRING_CST. (imm_store_chain_info::coalesce_immediate_stores): Set bit_insertion to true after changing MEM_REF stores into BIT_INSERT_EXPR stores. (count_multiple_uses): Return 0 for STRING_CST. (split_group): Do not split the group for a string concatenation. (imm_store_chain_info::output_merged_store): Constify and rename some local variables. Build an array type as destination type for a string concatenation, as well as a zero mask, and call build_string to build the source. (lhs_valid_for_store_merging_p): Return true for VIEW_CONVERT_EXPR. (pass_store_merging::process_store): Accept STRING_CST on the RHS. * gimple.h (gimple_call_alloca_for_var_p): New accessor function. * gimplify.c (gimplify_modify_expr_to_memcpy): Set alloca_for_var. * tree.h (CALL_ALLOCA_FOR_VAR_P): Document it for BUILT_IN_MEMCPY. gcc/testsuite/ChangeLog: * gnat.dg/opt87.adb: New test. * gnat.dg/opt87_pkg.ads: New helper. * gnat.dg/opt87_pkg.adb: Likewise.
2020-07-03 18:10:25 +02:00
else
invalid = true;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
unsigned HOST_WIDE_INT const_bitsize, const_bitpos;
unsigned HOST_WIDE_INT const_bitregion_start, const_bitregion_end;
if (invalid
|| !bitsize.is_constant (&const_bitsize)
|| !bitpos.is_constant (&const_bitpos)
|| !bitregion_start.is_constant (&const_bitregion_start)
|| !bitregion_end.is_constant (&const_bitregion_end))
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
return terminate_all_aliasing_chains (NULL, stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
if (!ins_stmt)
memset (&n, 0, sizeof (n));
PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs gcc/c/ChangeLog: PR c++/61339 * c-decl.c (xref_tag): Change class-key of PODs to struct and others to class. (field_decl_cmp): Same. * c-parser.c (c_parser_struct_or_union_specifier): Same. * c-tree.h: Same. * gimple-parser.c (c_parser_gimple_compound_statement): Same. gcc/c-family/ChangeLog: PR c++/61339 * c-opts.c (handle_deferred_opts): : Change class-key of PODs to struct and others to class. * c-pretty-print.h: Same. gcc/cp/ChangeLog: PR c++/61339 * cp-tree.h: Change class-key of PODs to struct and others to class. * search.c: Same. * semantics.c (finalize_nrv_r): Same. gcc/lto/ChangeLog: PR c++/61339 * lto-common.c (lto_splay_tree_new): : Change class-key of PODs to struct and others to class. (mentions_vars_p): Same. (register_resolution): Same. (lto_register_var_decl_in_symtab): Same. (lto_register_function_decl_in_symtab): Same. (cmp_tree): Same. (lto_read_decls): Same. gcc/ChangeLog: PR c++/61339 * auto-profile.c: Change class-key of PODs to struct and others to class. * basic-block.h: Same. * bitmap.c (bitmap_alloc): Same. * bitmap.h: Same. * builtins.c (expand_builtin_prefetch): Same. (expand_builtin_interclass_mathfn): Same. (expand_builtin_strlen): Same. (expand_builtin_mempcpy_args): Same. (expand_cmpstr): Same. (expand_builtin___clear_cache): Same. (expand_ifn_atomic_bit_test_and): Same. (expand_builtin_thread_pointer): Same. (expand_builtin_set_thread_pointer): Same. * caller-save.c (setup_save_areas): Same. (replace_reg_with_saved_mem): Same. (insert_restore): Same. (insert_save): Same. (add_used_regs): Same. * cfg.c (get_bb_copy): Same. (set_loop_copy): Same. * cfg.h: Same. * cfganal.h: Same. * cfgexpand.c (alloc_stack_frame_space): Same. (add_stack_var): Same. (add_stack_var_conflict): Same. (add_scope_conflicts_1): Same. (update_alias_info_with_stack_vars): Same. (expand_used_vars): Same. * cfghooks.c (redirect_edge_and_branch_force): Same. (delete_basic_block): Same. (split_edge): Same. (make_forwarder_block): Same. (force_nonfallthru): Same. (duplicate_block): Same. (lv_flush_pending_stmts): Same. * cfghooks.h: Same. * cfgloop.c (flow_loops_cfg_dump): Same. (flow_loop_nested_p): Same. (superloop_at_depth): Same. (get_loop_latch_edges): Same. (flow_loop_dump): Same. (flow_loops_dump): Same. (flow_loops_free): Same. (flow_loop_nodes_find): Same. (establish_preds): Same. (flow_loop_tree_node_add): Same. (flow_loop_tree_node_remove): Same. (flow_loops_find): Same. (find_subloop_latch_edge_by_profile): Same. (find_subloop_latch_edge_by_ivs): Same. (mfb_redirect_edges_in_set): Same. (form_subloop): Same. (merge_latch_edges): Same. (disambiguate_multiple_latches): Same. (disambiguate_loops_with_multiple_latches): Same. (flow_bb_inside_loop_p): Same. (glb_enum_p): Same. (get_loop_body_with_size): Same. (get_loop_body): Same. (fill_sons_in_loop): Same. (get_loop_body_in_dom_order): Same. (get_loop_body_in_custom_order): Same. (release_recorded_exits): Same. (get_loop_exit_edges): Same. (num_loop_branches): Same. (remove_bb_from_loops): Same. (find_common_loop): Same. (delete_loop): Same. (cancel_loop): Same. (verify_loop_structure): Same. (loop_preheader_edge): Same. (loop_exit_edge_p): Same. (single_exit): Same. (loop_exits_to_bb_p): Same. (loop_exits_from_bb_p): Same. (get_loop_location): Same. (record_niter_bound): Same. (get_estimated_loop_iterations_int): Same. (max_stmt_executions_int): Same. (likely_max_stmt_executions_int): Same. (get_estimated_loop_iterations): Same. (get_max_loop_iterations): Same. (get_max_loop_iterations_int): Same. (get_likely_max_loop_iterations): Same. * cfgloop.h (simple_loop_desc): Same. (get_loop): Same. (loop_depth): Same. (loop_outer): Same. (loop_iterator::next): Same. (loop_outermost): Same. * cfgloopanal.c (mark_irreducible_loops): Same. (num_loop_insns): Same. (average_num_loop_insns): Same. (expected_loop_iterations_unbounded): Same. (expected_loop_iterations): Same. (mark_loop_exit_edges): Same. (single_likely_exit): Same. * cfgloopmanip.c (fix_bb_placement): Same. (fix_bb_placements): Same. (remove_path): Same. (place_new_loop): Same. (add_loop): Same. (scale_loop_frequencies): Same. (scale_loop_profile): Same. (create_empty_if_region_on_edge): Same. (create_empty_loop_on_edge): Same. (loopify): Same. (unloop): Same. (fix_loop_placements): Same. (copy_loop_info): Same. (duplicate_loop): Same. (duplicate_subloops): Same. (loop_redirect_edge): Same. (can_duplicate_loop_p): Same. (duplicate_loop_to_header_edge): Same. (mfb_keep_just): Same. (has_preds_from_loop): Same. (create_preheader): Same. (create_preheaders): Same. (lv_adjust_loop_entry_edge): Same. (loop_version): Same. * cfgloopmanip.h: Same. * cgraph.h: Same. * cgraphbuild.c: Same. * combine.c (make_extraction): Same. * config/i386/i386-features.c: Same. * config/i386/i386-features.h: Same. * config/i386/i386.c (ix86_emit_outlined_ms2sysv_save): Same. (ix86_emit_outlined_ms2sysv_restore): Same. (ix86_noce_conversion_profitable_p): Same. (ix86_init_cost): Same. (ix86_simd_clone_usable): Same. * configure.ac: Same. * coretypes.h: Same. * data-streamer-in.c (string_for_index): Same. (streamer_read_indexed_string): Same. (streamer_read_string): Same. (bp_unpack_indexed_string): Same. (bp_unpack_string): Same. (streamer_read_uhwi): Same. (streamer_read_hwi): Same. (streamer_read_gcov_count): Same. (streamer_read_wide_int): Same. * data-streamer.h (streamer_write_bitpack): Same. (bp_unpack_value): Same. (streamer_write_char_stream): Same. (streamer_write_hwi_in_range): Same. (streamer_write_record_start): Same. * ddg.c (create_ddg_dep_from_intra_loop_link): Same. (add_cross_iteration_register_deps): Same. (build_intra_loop_deps): Same. * df-core.c (df_analyze): Same. (loop_post_order_compute): Same. (loop_inverted_post_order_compute): Same. * df-problems.c (df_rd_alloc): Same. (df_rd_simulate_one_insn): Same. (df_rd_local_compute): Same. (df_rd_init_solution): Same. (df_rd_confluence_n): Same. (df_rd_transfer_function): Same. (df_rd_free): Same. (df_rd_dump_defs_set): Same. (df_rd_top_dump): Same. (df_lr_alloc): Same. (df_lr_reset): Same. (df_lr_local_compute): Same. (df_lr_init): Same. (df_lr_confluence_n): Same. (df_lr_free): Same. (df_lr_top_dump): Same. (df_lr_verify_transfer_functions): Same. (df_live_alloc): Same. (df_live_reset): Same. (df_live_init): Same. (df_live_confluence_n): Same. (df_live_finalize): Same. (df_live_free): Same. (df_live_top_dump): Same. (df_live_verify_transfer_functions): Same. (df_mir_alloc): Same. (df_mir_reset): Same. (df_mir_init): Same. (df_mir_confluence_n): Same. (df_mir_free): Same. (df_mir_top_dump): Same. (df_word_lr_alloc): Same. (df_word_lr_reset): Same. (df_word_lr_init): Same. (df_word_lr_confluence_n): Same. (df_word_lr_free): Same. (df_word_lr_top_dump): Same. (df_md_alloc): Same. (df_md_simulate_one_insn): Same. (df_md_reset): Same. (df_md_init): Same. (df_md_free): Same. (df_md_top_dump): Same. * df-scan.c (df_insn_delete): Same. (df_insn_rescan): Same. (df_notes_rescan): Same. (df_sort_and_compress_mws): Same. (df_install_mws): Same. (df_refs_add_to_chains): Same. (df_ref_create_structure): Same. (df_ref_record): Same. (df_def_record_1): Same. (df_find_hard_reg_defs): Same. (df_uses_record): Same. (df_get_conditional_uses): Same. (df_get_call_refs): Same. (df_recompute_luids): Same. (df_get_entry_block_def_set): Same. (df_entry_block_defs_collect): Same. (df_get_exit_block_use_set): Same. (df_exit_block_uses_collect): Same. (df_mws_verify): Same. (df_bb_verify): Same. * df.h (df_scan_get_bb_info): Same. * doc/tm.texi: Same. * dse.c (record_store): Same. * dumpfile.h: Same. * emit-rtl.c (const_fixed_hasher::equal): Same. (set_mem_attributes_minus_bitpos): Same. (change_address): Same. (adjust_address_1): Same. (offset_address): Same. * emit-rtl.h: Same. * except.c (dw2_build_landing_pads): Same. (sjlj_emit_dispatch_table): Same. * explow.c (allocate_dynamic_stack_space): Same. (emit_stack_probe): Same. (probe_stack_range): Same. * expmed.c (store_bit_field_using_insv): Same. (store_bit_field_1): Same. (store_integral_bit_field): Same. (extract_bit_field_using_extv): Same. (extract_bit_field_1): Same. (emit_cstore): Same. * expr.c (emit_block_move_via_cpymem): Same. (expand_cmpstrn_or_cmpmem): Same. (set_storage_via_setmem): Same. (emit_single_push_insn_1): Same. (expand_assignment): Same. (store_constructor): Same. (expand_expr_real_2): Same. (expand_expr_real_1): Same. (try_casesi): Same. * flags.h: Same. * function.c (try_fit_stack_local): Same. (assign_stack_local_1): Same. (assign_stack_local): Same. (cut_slot_from_list): Same. (insert_slot_to_list): Same. (max_slot_level): Same. (move_slot_to_level): Same. (temp_address_hasher::equal): Same. (remove_unused_temp_slot_addresses): Same. (assign_temp): Same. (combine_temp_slots): Same. (update_temp_slot_address): Same. (preserve_temp_slots): Same. * function.h: Same. * fwprop.c: Same. * gcc-rich-location.h: Same. * gcov.c: Same. * genattrtab.c (check_attr_test): Same. (check_attr_value): Same. (convert_set_attr_alternative): Same. (convert_set_attr): Same. (check_defs): Same. (copy_boolean): Same. (get_attr_value): Same. (expand_delays): Same. (make_length_attrs): Same. (min_fn): Same. (make_alternative_compare): Same. (simplify_test_exp): Same. (tests_attr_p): Same. (get_attr_order): Same. (clear_struct_flag): Same. (gen_attr): Same. (compares_alternatives_p): Same. (gen_insn): Same. (gen_delay): Same. (find_attrs_to_cache): Same. (write_test_expr): Same. (walk_attr_value): Same. (write_attr_get): Same. (eliminate_known_true): Same. (write_insn_cases): Same. (write_attr_case): Same. (write_attr_valueq): Same. (write_attr_value): Same. (write_dummy_eligible_delay): Same. (next_comma_elt): Same. (find_attr): Same. (make_internal_attr): Same. (copy_rtx_unchanging): Same. (gen_insn_reserv): Same. (check_tune_attr): Same. (make_automaton_attrs): Same. (handle_arg): Same. * genextract.c (gen_insn): Same. (VEC_char_to_string): Same. * genmatch.c (print_operand): Same. (lower): Same. (parser::parse_operation): Same. (parser::parse_capture): Same. (parser::parse_c_expr): Same. (parser::parse_simplify): Same. (main): Same. * genoutput.c (output_operand_data): Same. (output_get_insn_name): Same. (compare_operands): Same. (place_operands): Same. (process_template): Same. (validate_insn_alternatives): Same. (validate_insn_operands): Same. (gen_expand): Same. (note_constraint): Same. * genpreds.c (write_one_predicate_function): Same. (add_constraint): Same. (process_define_register_constraint): Same. (write_lookup_constraint_1): Same. (write_lookup_constraint_array): Same. (write_insn_constraint_len): Same. (write_reg_class_for_constraint_1): Same. (write_constraint_satisfied_p_array): Same. * genrecog.c (optimize_subroutine_group): Same. * gensupport.c (process_define_predicate): Same. (queue_pattern): Same. (remove_from_queue): Same. (process_rtx): Same. (is_predicable): Same. (change_subst_attribute): Same. (subst_pattern_match): Same. (alter_constraints): Same. (alter_attrs_for_insn): Same. (shift_output_template): Same. (alter_output_for_subst_insn): Same. (process_one_cond_exec): Same. (subst_dup): Same. (process_define_cond_exec): Same. (mnemonic_htab_callback): Same. (gen_mnemonic_attr): Same. (read_md_rtx): Same. * ggc-page.c: Same. * gimple-loop-interchange.cc (dump_reduction): Same. (dump_induction): Same. (loop_cand::~loop_cand): Same. (free_data_refs_with_aux): Same. (tree_loop_interchange::interchange_loops): Same. (tree_loop_interchange::map_inductions_to_loop): Same. (tree_loop_interchange::move_code_to_inner_loop): Same. (compute_access_stride): Same. (compute_access_strides): Same. (proper_loop_form_for_interchange): Same. (tree_loop_interchange_compute_ddrs): Same. (prune_datarefs_not_in_loop): Same. (prepare_data_references): Same. (pass_linterchange::execute): Same. * gimple-loop-jam.c (bb_prevents_fusion_p): Same. (unroll_jam_possible_p): Same. (fuse_loops): Same. (adjust_unroll_factor): Same. (tree_loop_unroll_and_jam): Same. * gimple-loop-versioning.cc (loop_versioning::~loop_versioning): Same. (loop_versioning::expensive_stmt_p): Same. (loop_versioning::version_for_unity): Same. (loop_versioning::dump_inner_likelihood): Same. (loop_versioning::find_per_loop_multiplication): Same. (loop_versioning::analyze_term_using_scevs): Same. (loop_versioning::record_address_fragment): Same. (loop_versioning::analyze_expr): Same. (loop_versioning::analyze_blocks): Same. (loop_versioning::prune_conditions): Same. (loop_versioning::merge_loop_info): Same. (loop_versioning::add_loop_to_queue): Same. (loop_versioning::decide_whether_loop_is_versionable): Same. (loop_versioning::make_versioning_decisions): Same. (loop_versioning::implement_versioning_decisions): Same. * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_phis): Same. * gimple-ssa-store-merging.c (split_store::split_store): Same. (count_multiple_uses): Same. (split_group): Same. (imm_store_chain_info::output_merged_store): Same. (pass_store_merging::process_store): Same. * gimple-ssa-strength-reduction.c (slsr_process_phi): Same. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): Same. (is_max): Same. (alloca_call_type): Same. (pass_walloca::execute): Same. * gimple-streamer-in.c (input_phi): Same. (input_gimple_stmt): Same. * gimple-streamer.h: Same. * godump.c (go_force_record_alignment): Same. (go_format_type): Same. (go_output_type): Same. (go_output_fndecl): Same. (go_output_typedef): Same. (keyword_hash_init): Same. (find_dummy_types): Same. * graph.c (draw_cfg_nodes_no_loops): Same. (draw_cfg_nodes_for_loop): Same. * hard-reg-set.h (hard_reg_set_iter_next): Same. * hsa-brig.c: Same. * hsa-common.h (hsa_internal_fn_hasher::equal): Same. * hsa-dump.c (dump_hsa_cfun): Same. * hsa-gen.c (gen_function_def_parameters): Same. * hsa-regalloc.c (dump_hsa_cfun_regalloc): Same. * input.c (dump_line_table_statistics): Same. (test_lexer): Same. * input.h: Same. * internal-fn.c (get_multi_vector_move): Same. (expand_load_lanes_optab_fn): Same. (expand_GOMP_SIMT_ENTER_ALLOC): Same. (expand_GOMP_SIMT_EXIT): Same. (expand_GOMP_SIMT_LAST_LANE): Same. (expand_GOMP_SIMT_ORDERED_PRED): Same. (expand_GOMP_SIMT_VOTE_ANY): Same. (expand_GOMP_SIMT_XCHG_BFLY): Same. (expand_GOMP_SIMT_XCHG_IDX): Same. (expand_addsub_overflow): Same. (expand_neg_overflow): Same. (expand_mul_overflow): Same. (expand_call_mem_ref): Same. (expand_mask_load_optab_fn): Same. (expand_scatter_store_optab_fn): Same. (expand_gather_load_optab_fn): Same. * ipa-cp.c (ipa_get_parm_lattices): Same. (print_all_lattices): Same. (ignore_edge_p): Same. (build_toporder_info): Same. (free_toporder_info): Same. (push_node_to_stack): Same. (ipcp_lattice<valtype>::set_contains_variable): Same. (set_agg_lats_to_bottom): Same. (ipcp_bits_lattice::meet_with): Same. (set_single_call_flag): Same. (initialize_node_lattices): Same. (ipa_get_jf_ancestor_result): Same. (ipcp_verify_propagated_values): Same. (propagate_scalar_across_jump_function): Same. (propagate_context_across_jump_function): Same. (propagate_bits_across_jump_function): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (set_check_aggs_by_ref): Same. (set_chain_of_aglats_contains_variable): Same. (merge_aggregate_lattices): Same. (agg_pass_through_permissible_p): Same. (propagate_aggs_across_jump_function): Same. (call_passes_through_thunk_p): Same. (propagate_constants_across_call): Same. (devirtualization_time_bonus): Same. (good_cloning_opportunity_p): Same. (context_independent_aggregate_values): Same. (gather_context_independent_values): Same. (perform_estimation_of_a_value): Same. (estimate_local_effects): Same. (value_topo_info<valtype>::add_val): Same. (add_all_node_vals_to_toposort): Same. (value_topo_info<valtype>::propagate_effects): Same. (ipcp_propagate_stage): Same. (ipcp_discover_new_direct_edges): Same. (same_node_or_its_all_contexts_clone_p): Same. (cgraph_edge_brings_value_p): Same. (gather_edges_for_value): Same. (create_specialized_node): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (copy_plats_to_inter): Same. (intersect_aggregates_with_edge): Same. (find_aggregate_values_for_callers_subset): Same. (cgraph_edge_brings_all_agg_vals_for_node): Same. (decide_about_value): Same. (decide_whether_version_node): Same. (spread_undeadness): Same. (identify_dead_nodes): Same. (ipcp_store_vr_results): Same. * ipa-devirt.c (final_warning_record::grow_type_warnings): Same. * ipa-fnsummary.c (ipa_fn_summary::account_size_time): Same. (redirect_to_unreachable): Same. (edge_set_predicate): Same. (evaluate_conditions_for_known_args): Same. (evaluate_properties_for_edge): Same. (ipa_fn_summary_t::duplicate): Same. (ipa_call_summary_t::duplicate): Same. (dump_ipa_call_summary): Same. (ipa_dump_fn_summary): Same. (eliminated_by_inlining_prob): Same. (set_cond_stmt_execution_predicate): Same. (set_switch_stmt_execution_predicate): Same. (compute_bb_predicates): Same. (will_be_nonconstant_expr_predicate): Same. (phi_result_unknown_predicate): Same. (analyze_function_body): Same. (compute_fn_summary): Same. (estimate_edge_devirt_benefit): Same. (estimate_edge_size_and_time): Same. (estimate_calls_size_and_time): Same. (estimate_node_size_and_time): Same. (remap_edge_change_prob): Same. (remap_edge_summaries): Same. (ipa_merge_fn_summary_after_inlining): Same. (ipa_fn_summary_generate): Same. (inline_read_section): Same. (ipa_fn_summary_read): Same. (ipa_fn_summary_write): Same. * ipa-fnsummary.h: Same. * ipa-hsa.c (ipa_hsa_read_section): Same. * ipa-icf-gimple.c (func_checker::compare_loops): Same. * ipa-icf.c (sem_function::param_used_p): Same. * ipa-inline-analysis.c (do_estimate_edge_time): Same. * ipa-inline.c (edge_badness): Same. (inline_small_functions): Same. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::stream_out): Same. * ipa-predicate.c (predicate::remap_after_duplication): Same. (predicate::remap_after_inlining): Same. (predicate::stream_out): Same. * ipa-predicate.h: Same. * ipa-profile.c (ipa_profile_read_summary): Same. * ipa-prop.c (ipa_get_param_decl_index_1): Same. (count_formal_params): Same. (ipa_dump_param): Same. (ipa_alloc_node_params): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_print_node_jump_functions): Same. (ipa_load_from_parm_agg): Same. (get_ancestor_addr_info): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_analyze_virtual_call_uses): Same. (ipa_analyze_stmt_uses): Same. (ipa_analyze_params_uses_in_bb): Same. (update_jump_functions_after_inlining): Same. (try_decrement_rdesc_refcount): Same. (ipa_impossible_devirt_target): Same. (update_indirect_edges_after_inlining): Same. (combine_controlled_uses_counters): Same. (ipa_edge_args_sum_t::duplicate): Same. (ipa_write_jump_function): Same. (ipa_write_indirect_edge_info): Same. (ipa_write_node_info): Same. (ipa_read_edge_info): Same. (ipa_prop_read_section): Same. (read_replacements_section): Same. * ipa-prop.h (ipa_get_param_count): Same. (ipa_get_param): Same. (ipa_get_type): Same. (ipa_get_param_move_cost): Same. (ipa_set_param_used): Same. (ipa_get_controlled_uses): Same. (ipa_set_controlled_uses): Same. (ipa_get_cs_argument_count): Same. * ipa-pure-const.c (analyze_function): Same. (pure_const_read_summary): Same. * ipa-ref.h: Same. * ipa-reference.c (ipa_reference_read_optimization_summary): Same. * ipa-split.c (test_nonssa_use): Same. (dump_split_point): Same. (dominated_by_forbidden): Same. (split_part_set_ssa_name_p): Same. (find_split_points): Same. * ira-build.c (finish_loop_tree_nodes): Same. (low_pressure_loop_node_p): Same. * ira-color.c (ira_reuse_stack_slot): Same. * ira-int.h: Same. * ira.c (setup_reg_equiv): Same. (print_insn_chain): Same. (ira): Same. * loop-doloop.c (doloop_condition_get): Same. (add_test): Same. (record_reg_sets): Same. (doloop_optimize): Same. * loop-init.c (loop_optimizer_init): Same. (fix_loop_structure): Same. * loop-invariant.c (merge_identical_invariants): Same. (compute_always_reached): Same. (find_exits): Same. (may_assign_reg_p): Same. (find_invariants_bb): Same. (find_invariants_body): Same. (replace_uses): Same. (can_move_invariant_reg): Same. (free_inv_motion_data): Same. (move_single_loop_invariants): Same. (change_pressure): Same. (mark_ref_regs): Same. (calculate_loop_reg_pressure): Same. * loop-iv.c (biv_entry_hasher::equal): Same. (iv_extend_to_rtx_code): Same. (check_iv_ref_table_size): Same. (clear_iv_info): Same. (latch_dominating_def): Same. (iv_get_reaching_def): Same. (iv_constant): Same. (iv_subreg): Same. (iv_extend): Same. (iv_neg): Same. (iv_add): Same. (iv_mult): Same. (get_biv_step): Same. (record_iv): Same. (analyzed_for_bivness_p): Same. (record_biv): Same. (iv_analyze_biv): Same. (iv_analyze_expr): Same. (iv_analyze_def): Same. (iv_analyze_op): Same. (iv_analyze): Same. (iv_analyze_result): Same. (biv_p): Same. (eliminate_implied_conditions): Same. (simplify_using_initial_values): Same. (shorten_into_mode): Same. (canonicalize_iv_subregs): Same. (determine_max_iter): Same. (check_simple_exit): Same. (find_simple_exit): Same. (get_simple_loop_desc): Same. * loop-unroll.c (report_unroll): Same. (decide_unrolling): Same. (unroll_loops): Same. (loop_exit_at_end_p): Same. (decide_unroll_constant_iterations): Same. (unroll_loop_constant_iterations): Same. (compare_and_jump_seq): Same. (unroll_loop_runtime_iterations): Same. (decide_unroll_stupid): Same. (unroll_loop_stupid): Same. (referenced_in_one_insn_in_loop_p): Same. (reset_debug_uses_in_loop): Same. (analyze_iv_to_split_insn): Same. * lra-eliminations.c (lra_debug_elim_table): Same. (setup_can_eliminate): Same. (form_sum): Same. (lra_get_elimination_hard_regno): Same. (lra_eliminate_regs_1): Same. (eliminate_regs_in_insn): Same. (update_reg_eliminate): Same. (init_elimination): Same. (lra_eliminate): Same. * lra-int.h: Same. * lra-lives.c (initiate_live_solver): Same. * lra-remat.c (create_remat_bb_data): Same. * lra-spills.c (lra_spill): Same. * lra.c (lra_set_insn_recog_data): Same. (lra_set_used_insn_alternative_by_uid): Same. (init_reg_info): Same. (expand_reg_info): Same. * lto-cgraph.c (output_symtab): Same. (read_identifier): Same. (get_alias_symbol): Same. (input_node): Same. (input_varpool_node): Same. (input_ref): Same. (input_edge): Same. (input_cgraph_1): Same. (input_refs): Same. (input_symtab): Same. (input_offload_tables): Same. (output_cgraph_opt_summary): Same. (input_edge_opt_summary): Same. (input_cgraph_opt_section): Same. * lto-section-in.c (lto_free_raw_section_data): Same. (lto_create_simple_input_block): Same. (lto_free_function_in_decl_state_for_node): Same. * lto-streamer-in.c (lto_tag_check_set): Same. (lto_location_cache::revert_location_cache): Same. (lto_location_cache::input_location): Same. (lto_input_location): Same. (stream_input_location_now): Same. (lto_input_tree_ref): Same. (lto_input_eh_catch_list): Same. (input_eh_region): Same. (lto_init_eh): Same. (make_new_block): Same. (input_cfg): Same. (fixup_call_stmt_edges): Same. (input_struct_function_base): Same. (input_function): Same. (lto_read_body_or_constructor): Same. (lto_read_tree_1): Same. (lto_read_tree): Same. (lto_input_scc): Same. (lto_input_tree_1): Same. (lto_input_toplevel_asms): Same. (lto_input_mode_table): Same. (lto_reader_init): Same. (lto_data_in_create): Same. * lto-streamer-out.c (output_cfg): Same. * lto-streamer.h: Same. * modulo-sched.c (duplicate_insns_of_cycles): Same. (generate_prolog_epilog): Same. (mark_loop_unsched): Same. (dump_insn_location): Same. (loop_canon_p): Same. (sms_schedule): Same. * omp-expand.c (expand_omp_for_ordered_loops): Same. (expand_omp_for_generic): Same. (expand_omp_for_static_nochunk): Same. (expand_omp_for_static_chunk): Same. (expand_omp_simd): Same. (expand_omp_taskloop_for_inner): Same. (expand_oacc_for): Same. (expand_omp_atomic_pipeline): Same. (mark_loops_in_oacc_kernels_region): Same. * omp-offload.c (oacc_xform_loop): Same. * omp-simd-clone.c (simd_clone_adjust): Same. * optabs-query.c (get_traditional_extraction_insn): Same. * optabs.c (expand_vector_broadcast): Same. (expand_binop_directly): Same. (expand_twoval_unop): Same. (expand_twoval_binop): Same. (expand_unop_direct): Same. (emit_indirect_jump): Same. (emit_conditional_move): Same. (emit_conditional_neg_or_complement): Same. (emit_conditional_add): Same. (vector_compare_rtx): Same. (expand_vec_perm_1): Same. (expand_vec_perm_const): Same. (expand_vec_cond_expr): Same. (expand_vec_series_expr): Same. (maybe_emit_atomic_exchange): Same. (maybe_emit_sync_lock_test_and_set): Same. (expand_atomic_compare_and_swap): Same. (expand_atomic_load): Same. (expand_atomic_store): Same. (maybe_emit_op): Same. (valid_multiword_target_p): Same. (create_integer_operand): Same. (maybe_legitimize_operand_same_code): Same. (maybe_legitimize_operand): Same. (create_convert_operand_from_type): Same. (can_reuse_operands_p): Same. (maybe_legitimize_operands): Same. (maybe_gen_insn): Same. (maybe_expand_insn): Same. (maybe_expand_jump_insn): Same. (expand_insn): Same. * optabs.h (create_expand_operand): Same. (create_fixed_operand): Same. (create_output_operand): Same. (create_input_operand): Same. (create_convert_operand_to): Same. (create_convert_operand_from): Same. * optinfo.h: Same. * poly-int.h: Same. * predict.c (optimize_insn_for_speed_p): Same. (optimize_loop_for_size_p): Same. (optimize_loop_for_speed_p): Same. (optimize_loop_nest_for_speed_p): Same. (get_base_value): Same. (predicted_by_loop_heuristics_p): Same. (predict_extra_loop_exits): Same. (predict_loops): Same. (predict_paths_for_bb): Same. (predict_paths_leading_to): Same. (propagate_freq): Same. (pass_profile::execute): Same. * predict.h: Same. * profile-count.c (profile_count::differs_from_p): Same. (profile_probability::differs_lot_from_p): Same. * profile-count.h: Same. * profile.c (branch_prob): Same. * regrename.c (free_chain_data): Same. (mark_conflict): Same. (create_new_chain): Same. (merge_overlapping_regs): Same. (init_rename_info): Same. (merge_chains): Same. (regrename_analyze): Same. (regrename_do_replace): Same. (scan_rtx_reg): Same. (record_out_operands): Same. (build_def_use): Same. * regrename.h: Same. * reload.h: Same. * reload1.c (init_reload): Same. (maybe_fix_stack_asms): Same. (copy_reloads): Same. (count_pseudo): Same. (count_spilled_pseudo): Same. (find_reg): Same. (find_reload_regs): Same. (select_reload_regs): Same. (spill_hard_reg): Same. (fixup_eh_region_note): Same. (set_reload_reg): Same. (allocate_reload_reg): Same. (compute_reload_subreg_offset): Same. (reload_adjust_reg_for_icode): Same. (emit_input_reload_insns): Same. (emit_output_reload_insns): Same. (do_input_reload): Same. (inherit_piecemeal_p): Same. * rtl.h: Same. * sanopt.c (maybe_get_dominating_check): Same. (maybe_optimize_ubsan_ptr_ifn): Same. (can_remove_asan_check): Same. (maybe_optimize_asan_check_ifn): Same. (sanopt_optimize_walker): Same. * sched-deps.c (add_dependence_list): Same. (chain_to_prev_insn): Same. (add_insn_mem_dependence): Same. (create_insn_reg_set): Same. (maybe_extend_reg_info_p): Same. (sched_analyze_reg): Same. (sched_analyze_1): Same. (get_implicit_reg_pending_clobbers): Same. (chain_to_prev_insn_p): Same. (deps_analyze_insn): Same. (deps_start_bb): Same. (sched_free_deps): Same. (init_deps): Same. (init_deps_reg_last): Same. (free_deps): Same. * sched-ebb.c: Same. * sched-int.h: Same. * sched-rgn.c (add_branch_dependences): Same. (concat_insn_mem_list): Same. (deps_join): Same. (sched_rgn_compute_dependencies): Same. * sel-sched-ir.c (reset_target_context): Same. (copy_deps_context): Same. (init_id_from_df): Same. (has_dependence_p): Same. (change_loops_latches): Same. (bb_top_order_comparator): Same. (make_region_from_loop_preheader): Same. (sel_init_pipelining): Same. (get_loop_nest_for_rgn): Same. (make_regions_from_the_rest): Same. (sel_is_loop_preheader_p): Same. * sel-sched-ir.h (inner_loop_header_p): Same. (get_all_loop_exits): Same. * selftest.h: Same. * sese.c (sese_build_liveouts): Same. (sese_insert_phis_for_liveouts): Same. * sese.h (defined_in_sese_p): Same. * sreal.c (sreal::stream_out): Same. * sreal.h: Same. * streamer-hooks.h: Same. * target-globals.c (save_target_globals): Same. * target-globals.h: Same. * target.def: Same. * target.h: Same. * targhooks.c (default_has_ifunc_p): Same. (default_empty_mask_is_expensive): Same. (default_init_cost): Same. * targhooks.h: Same. * toplev.c: Same. * tree-affine.c (aff_combination_mult): Same. (aff_combination_expand): Same. (aff_combination_constant_multiple_p): Same. * tree-affine.h: Same. * tree-cfg.c (build_gimple_cfg): Same. (replace_loop_annotate_in_block): Same. (replace_uses_by): Same. (remove_bb): Same. (dump_cfg_stats): Same. (gimple_duplicate_sese_region): Same. (gimple_duplicate_sese_tail): Same. (move_block_to_fn): Same. (replace_block_vars_by_duplicates): Same. (move_sese_region_to_fn): Same. (print_loops_bb): Same. (print_loop): Same. (print_loops): Same. (debug): Same. (debug_loops): Same. * tree-cfg.h: Same. * tree-chrec.c (chrec_fold_plus_poly_poly): Same. (chrec_fold_multiply_poly_poly): Same. (chrec_evaluate): Same. (chrec_component_in_loop_num): Same. (reset_evolution_in_loop): Same. (is_multivariate_chrec): Same. (chrec_contains_symbols): Same. (nb_vars_in_chrec): Same. (chrec_convert_1): Same. (chrec_convert_aggressive): Same. * tree-chrec.h: Same. * tree-core.h: Same. * tree-data-ref.c (dump_data_dependence_relation): Same. (canonicalize_base_object_address): Same. (data_ref_compare_tree): Same. (prune_runtime_alias_test_list): Same. (get_segment_min_max): Same. (create_intersect_range_checks): Same. (conflict_fn_no_dependence): Same. (object_address_invariant_in_loop_p): Same. (analyze_ziv_subscript): Same. (analyze_siv_subscript_cst_affine): Same. (analyze_miv_subscript): Same. (analyze_overlapping_iterations): Same. (build_classic_dist_vector_1): Same. (add_other_self_distances): Same. (same_access_functions): Same. (build_classic_dir_vector): Same. (subscript_dependence_tester_1): Same. (subscript_dependence_tester): Same. (access_functions_are_affine_or_constant_p): Same. (get_references_in_stmt): Same. (loop_nest_has_data_refs): Same. (graphite_find_data_references_in_stmt): Same. (find_data_references_in_bb): Same. (get_base_for_alignment): Same. (find_loop_nest_1): Same. (find_loop_nest): Same. * tree-data-ref.h (dr_alignment): Same. (ddr_dependence_level): Same. * tree-if-conv.c (fold_build_cond_expr): Same. (add_to_predicate_list): Same. (add_to_dst_predicate_list): Same. (phi_convertible_by_degenerating_args): Same. (idx_within_array_bound): Same. (all_preds_critical_p): Same. (pred_blocks_visited_p): Same. (predicate_bbs): Same. (build_region): Same. (if_convertible_loop_p_1): Same. (is_cond_scalar_reduction): Same. (predicate_scalar_phi): Same. (remove_conditions_and_labels): Same. (combine_blocks): Same. (version_loop_for_if_conversion): Same. (versionable_outer_loop_p): Same. (ifcvt_local_dce): Same. (tree_if_conversion): Same. (pass_if_conversion::gate): Same. * tree-if-conv.h: Same. * tree-inline.c (maybe_move_debug_stmts_to_successors): Same. * tree-loop-distribution.c (bb_top_order_cmp): Same. (free_rdg): Same. (stmt_has_scalar_dependences_outside_loop): Same. (copy_loop_before): Same. (create_bb_after_loop): Same. (const_with_all_bytes_same): Same. (generate_memset_builtin): Same. (generate_memcpy_builtin): Same. (destroy_loop): Same. (build_rdg_partition_for_vertex): Same. (compute_access_range): Same. (data_ref_segment_size): Same. (latch_dominated_by_data_ref): Same. (compute_alias_check_pairs): Same. (fuse_memset_builtins): Same. (finalize_partitions): Same. (find_seed_stmts_for_distribution): Same. (prepare_perfect_loop_nest): Same. * tree-parloops.c (lambda_transform_legal_p): Same. (loop_parallel_p): Same. (reduc_stmt_res): Same. (add_field_for_name): Same. (create_call_for_reduction_1): Same. (replace_uses_in_bb_by): Same. (transform_to_exit_first_loop_alt): Same. (try_transform_to_exit_first_loop_alt): Same. (transform_to_exit_first_loop): Same. (num_phis): Same. (gen_parallel_loop): Same. (gather_scalar_reductions): Same. (get_omp_data_i_param): Same. (try_create_reduction_list): Same. (oacc_entry_exit_single_gang): Same. (parallelize_loops): Same. * tree-pass.h: Same. * tree-predcom.c (determine_offset): Same. (last_always_executed_block): Same. (split_data_refs_to_components): Same. (suitable_component_p): Same. (valid_initializer_p): Same. (find_looparound_phi): Same. (insert_looparound_copy): Same. (add_looparound_copies): Same. (determine_roots_comp): Same. (predcom_tmp_var): Same. (initialize_root_vars): Same. (initialize_root_vars_store_elim_1): Same. (initialize_root_vars_store_elim_2): Same. (finalize_eliminated_stores): Same. (initialize_root_vars_lm): Same. (remove_stmt): Same. (determine_unroll_factor): Same. (execute_pred_commoning_cbck): Same. (base_names_in_chain_on): Same. (combine_chains): Same. (pcom_stmt_dominates_stmt_p): Same. (try_combine_chains): Same. (prepare_initializers_chain_store_elim): Same. (prepare_initializers_chain): Same. (prepare_initializers): Same. (prepare_finalizers_chain): Same. (prepare_finalizers): Same. (insert_init_seqs): Same. * tree-scalar-evolution.c (loop_phi_node_p): Same. (compute_overall_effect_of_inner_loop): Same. (add_to_evolution_1): Same. (add_to_evolution): Same. (follow_ssa_edge_binary): Same. (follow_ssa_edge_expr): Same. (backedge_phi_arg_p): Same. (follow_ssa_edge_in_condition_phi_branch): Same. (follow_ssa_edge_in_condition_phi): Same. (follow_ssa_edge_inner_loop_phi): Same. (follow_ssa_edge): Same. (analyze_evolution_in_loop): Same. (analyze_initial_condition): Same. (interpret_loop_phi): Same. (interpret_condition_phi): Same. (interpret_rhs_expr): Same. (interpret_expr): Same. (interpret_gimple_assign): Same. (analyze_scalar_evolution_1): Same. (analyze_scalar_evolution): Same. (analyze_scalar_evolution_for_address_of): Same. (get_instantiated_value_entry): Same. (loop_closed_phi_def): Same. (instantiate_scev_name): Same. (instantiate_scev_poly): Same. (instantiate_scev_binary): Same. (instantiate_scev_convert): Same. (instantiate_scev_not): Same. (instantiate_scev_r): Same. (instantiate_scev): Same. (resolve_mixers): Same. (initialize_scalar_evolutions_analyzer): Same. (scev_reset_htab): Same. (scev_reset): Same. (derive_simple_iv_with_niters): Same. (simple_iv_with_niters): Same. (expression_expensive_p): Same. (final_value_replacement_loop): Same. * tree-scalar-evolution.h (block_before_loop): Same. * tree-ssa-address.h: Same. * tree-ssa-dce.c (find_obviously_necessary_stmts): Same. * tree-ssa-dom.c (edge_info::record_simple_equiv): Same. (record_edge_info): Same. * tree-ssa-live.c (var_map_base_fini): Same. (remove_unused_locals): Same. * tree-ssa-live.h: Same. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Same. (pass_ch_vect::execute): Same. (pass_ch::process_loop_p): Same. * tree-ssa-loop-im.c (mem_ref_hasher::hash): Same. (movement_possibility): Same. (outermost_invariant_loop): Same. (stmt_cost): Same. (determine_max_movement): Same. (invariantness_dom_walker::before_dom_children): Same. (move_computations): Same. (may_move_till): Same. (force_move_till_op): Same. (force_move_till): Same. (memref_free): Same. (record_mem_ref_loc): Same. (set_ref_stored_in_loop): Same. (mark_ref_stored): Same. (sort_bbs_in_loop_postorder_cmp): Same. (sort_locs_in_loop_postorder_cmp): Same. (analyze_memory_references): Same. (mem_refs_may_alias_p): Same. (find_ref_loc_in_loop_cmp): Same. (rewrite_mem_ref_loc::operator): Same. (first_mem_ref_loc_1::operator): Same. (sm_set_flag_if_changed::operator): Same. (execute_sm_if_changed_flag_set): Same. (execute_sm): Same. (hoist_memory_references): Same. (ref_always_accessed::operator): Same. (refs_independent_p): Same. (record_dep_loop): Same. (ref_indep_loop_p_1): Same. (ref_indep_loop_p): Same. (can_sm_ref_p): Same. (find_refs_for_sm): Same. (loop_suitable_for_sm): Same. (store_motion_loop): Same. (store_motion): Same. (fill_always_executed_in): Same. * tree-ssa-loop-ivcanon.c (constant_after_peeling): Same. (estimated_unrolled_size): Same. (loop_edge_to_cancel): Same. (remove_exits_and_undefined_stmts): Same. (remove_redundant_iv_tests): Same. (unloop_loops): Same. (estimated_peeled_sequence_size): Same. (try_peel_loop): Same. (canonicalize_loop_induction_variables): Same. (canonicalize_induction_variables): Same. * tree-ssa-loop-ivopts.c (iv_inv_expr_hasher::equal): Same. (name_info): Same. (stmt_after_inc_pos): Same. (contains_abnormal_ssa_name_p): Same. (niter_for_exit): Same. (find_bivs): Same. (mark_bivs): Same. (find_givs_in_bb): Same. (find_induction_variables): Same. (find_interesting_uses_cond): Same. (outermost_invariant_loop_for_expr): Same. (idx_find_step): Same. (add_candidate_1): Same. (add_iv_candidate_derived_from_uses): Same. (alloc_use_cost_map): Same. (prepare_decl_rtl): Same. (generic_predict_doloop_p): Same. (computation_cost): Same. (determine_common_wider_type): Same. (get_computation_aff_1): Same. (get_use_type): Same. (determine_group_iv_cost_address): Same. (iv_period): Same. (difference_cannot_overflow_p): Same. (may_eliminate_iv): Same. (determine_set_costs): Same. (cheaper_cost_pair): Same. (compare_cost_pair): Same. (iv_ca_cand_for_group): Same. (iv_ca_recount_cost): Same. (iv_ca_set_remove_invs): Same. (iv_ca_set_no_cp): Same. (iv_ca_set_add_invs): Same. (iv_ca_set_cp): Same. (iv_ca_add_group): Same. (iv_ca_cost): Same. (iv_ca_compare_deps): Same. (iv_ca_delta_reverse): Same. (iv_ca_delta_commit): Same. (iv_ca_cand_used_p): Same. (iv_ca_delta_free): Same. (iv_ca_new): Same. (iv_ca_free): Same. (iv_ca_dump): Same. (iv_ca_extend): Same. (iv_ca_narrow): Same. (iv_ca_prune): Same. (cheaper_cost_with_cand): Same. (iv_ca_replace): Same. (try_add_cand_for): Same. (get_initial_solution): Same. (try_improve_iv_set): Same. (find_optimal_iv_set_1): Same. (create_new_iv): Same. (rewrite_use_compare): Same. (remove_unused_ivs): Same. (determine_scaling_factor): Same. * tree-ssa-loop-ivopts.h: Same. * tree-ssa-loop-manip.c (create_iv): Same. (compute_live_loop_exits): Same. (add_exit_phi): Same. (add_exit_phis): Same. (find_uses_to_rename_use): Same. (find_uses_to_rename_def): Same. (find_uses_to_rename_in_loop): Same. (rewrite_into_loop_closed_ssa): Same. (check_loop_closed_ssa_bb): Same. (split_loop_exit_edge): Same. (ip_end_pos): Same. (ip_normal_pos): Same. (copy_phi_node_args): Same. (gimple_duplicate_loop_to_header_edge): Same. (can_unroll_loop_p): Same. (determine_exit_conditions): Same. (scale_dominated_blocks_in_loop): Same. (niter_for_unrolled_loop): Same. (tree_transform_and_unroll_loop): Same. (rewrite_all_phi_nodes_with_iv): Same. * tree-ssa-loop-manip.h: Same. * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Same. (number_of_iterations_ne): Same. (assert_no_overflow_lt): Same. (assert_loop_rolls_lt): Same. (number_of_iterations_lt): Same. (adjust_cond_for_loop_until_wrap): Same. (tree_simplify_using_condition): Same. (simplify_using_initial_conditions): Same. (simplify_using_outer_evolutions): Same. (loop_only_exit_p): Same. (ssa_defined_by_minus_one_stmt_p): Same. (number_of_iterations_popcount): Same. (number_of_iterations_exit): Same. (find_loop_niter): Same. (finite_loop_p): Same. (chain_of_csts_start): Same. (get_val_for): Same. (loop_niter_by_eval): Same. (derive_constant_upper_bound_ops): Same. (do_warn_aggressive_loop_optimizations): Same. (record_estimate): Same. (get_cst_init_from_scev): Same. (record_nonwrapping_iv): Same. (idx_infer_loop_bounds): Same. (infer_loop_bounds_from_ref): Same. (infer_loop_bounds_from_array): Same. (infer_loop_bounds_from_pointer_arith): Same. (infer_loop_bounds_from_signedness): Same. (bound_index): Same. (discover_iteration_bound_by_body_walk): Same. (maybe_lower_iteration_bound): Same. (estimate_numbers_of_iterations): Same. (estimated_loop_iterations): Same. (estimated_loop_iterations_int): Same. (max_loop_iterations): Same. (max_loop_iterations_int): Same. (likely_max_loop_iterations): Same. (likely_max_loop_iterations_int): Same. (estimated_stmt_executions_int): Same. (max_stmt_executions): Same. (likely_max_stmt_executions): Same. (estimated_stmt_executions): Same. (stmt_dominates_stmt_p): Same. (nowrap_type_p): Same. (loop_exits_before_overflow): Same. (scev_var_range_cant_overflow): Same. (scev_probably_wraps_p): Same. (free_numbers_of_iterations_estimates): Same. * tree-ssa-loop-niter.h: Same. * tree-ssa-loop-prefetch.c (release_mem_refs): Same. (idx_analyze_ref): Same. (analyze_ref): Same. (gather_memory_references_ref): Same. (mark_nontemporal_store): Same. (emit_mfence_after_loop): Same. (may_use_storent_in_loop_p): Same. (mark_nontemporal_stores): Same. (should_unroll_loop_p): Same. (volume_of_dist_vector): Same. (add_subscript_strides): Same. (self_reuse_distance): Same. (insn_to_prefetch_ratio_too_small_p): Same. * tree-ssa-loop-split.c (split_at_bb_p): Same. (patch_loop_exit): Same. (find_or_create_guard_phi): Same. (easy_exit_values): Same. (connect_loop_phis): Same. (connect_loops): Same. (compute_new_first_bound): Same. (split_loop): Same. (tree_ssa_split_loops): Same. * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Same. (is_maybe_undefined): Same. (tree_may_unswitch_on): Same. (simplify_using_entry_checks): Same. (tree_unswitch_single_loop): Same. (tree_unswitch_loop): Same. (tree_unswitch_outer_loop): Same. (empty_bb_without_guard_p): Same. (used_outside_loop_p): Same. (get_vop_from_header): Same. (hoist_guard): Same. * tree-ssa-loop.c (gate_oacc_kernels): Same. (get_lsm_tmp_name): Same. * tree-ssa-loop.h: Same. * tree-ssa-reassoc.c (add_repeat_to_ops_vec): Same. (build_and_add_sum): Same. (no_side_effect_bb): Same. (get_ops): Same. (linearize_expr): Same. (should_break_up_subtract): Same. (linearize_expr_tree): Same. * tree-ssa-scopedtables.c: Same. * tree-ssa-scopedtables.h: Same. * tree-ssa-structalias.c (condense_visit): Same. (label_visit): Same. (dump_pred_graph): Same. (perform_var_substitution): Same. (move_complex_constraints): Same. (remove_preds_and_fake_succs): Same. * tree-ssa-threadupdate.c (dbds_continue_enumeration_p): Same. (determine_bb_domination_status): Same. (duplicate_thread_path): Same. (thread_through_all_blocks): Same. * tree-ssa-threadupdate.h: Same. * tree-streamer-in.c (streamer_read_string_cst): Same. (input_identifier): Same. (unpack_ts_type_common_value_fields): Same. (unpack_ts_block_value_fields): Same. (unpack_ts_translation_unit_decl_value_fields): Same. (unpack_ts_omp_clause_value_fields): Same. (streamer_read_tree_bitfields): Same. (streamer_alloc_tree): Same. (lto_input_ts_common_tree_pointers): Same. (lto_input_ts_vector_tree_pointers): Same. (lto_input_ts_poly_tree_pointers): Same. (lto_input_ts_complex_tree_pointers): Same. (lto_input_ts_decl_minimal_tree_pointers): Same. (lto_input_ts_decl_common_tree_pointers): Same. (lto_input_ts_decl_non_common_tree_pointers): Same. (lto_input_ts_decl_with_vis_tree_pointers): Same. (lto_input_ts_field_decl_tree_pointers): Same. (lto_input_ts_function_decl_tree_pointers): Same. (lto_input_ts_type_common_tree_pointers): Same. (lto_input_ts_type_non_common_tree_pointers): Same. (lto_input_ts_list_tree_pointers): Same. (lto_input_ts_vec_tree_pointers): Same. (lto_input_ts_exp_tree_pointers): Same. (lto_input_ts_block_tree_pointers): Same. (lto_input_ts_binfo_tree_pointers): Same. (lto_input_ts_constructor_tree_pointers): Same. (lto_input_ts_omp_clause_tree_pointers): Same. (streamer_read_tree_body): Same. * tree-streamer.h: Same. * tree-switch-conversion.c (bit_test_cluster::is_beneficial): Same. * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Same. (vect_analyze_possibly_independent_ddr): Same. (vect_analyze_data_ref_dependence): Same. (vect_compute_data_ref_alignment): Same. (vect_enhance_data_refs_alignment): Same. (vect_analyze_data_ref_access): Same. (vect_check_gather_scatter): Same. (vect_find_stmt_data_reference): Same. (vect_create_addr_base_for_vector_ref): Same. (vect_setup_realignment): Same. (vect_supportable_dr_alignment): Same. * tree-vect-loop-manip.c (rename_variables_in_bb): Same. (adjust_phi_and_debug_stmts): Same. (vect_set_loop_mask): Same. (add_preheader_seq): Same. (vect_maybe_permute_loop_masks): Same. (vect_set_loop_masks_directly): Same. (vect_set_loop_condition_masked): Same. (vect_set_loop_condition_unmasked): Same. (slpeel_duplicate_current_defs_from_edges): Same. (slpeel_add_loop_guard): Same. (slpeel_can_duplicate_loop_p): Same. (create_lcssa_for_virtual_phi): Same. (iv_phi_p): Same. (vect_update_ivs_after_vectorizer): Same. (vect_gen_vector_loop_niters_mult_vf): Same. (slpeel_update_phi_nodes_for_loops): Same. (slpeel_update_phi_nodes_for_guard1): Same. (find_guard_arg): Same. (slpeel_update_phi_nodes_for_guard2): Same. (slpeel_update_phi_nodes_for_lcssa): Same. (vect_do_peeling): Same. (vect_create_cond_for_alias_checks): Same. (vect_loop_versioning): Same. * tree-vect-loop.c (vect_determine_vf_for_stmt): Same. (vect_inner_phi_in_double_reduction_p): Same. (vect_analyze_scalar_cycles_1): Same. (vect_fixup_scalar_cycles_with_patterns): Same. (vect_get_loop_niters): Same. (bb_in_loop_p): Same. (vect_get_max_nscalars_per_iter): Same. (vect_verify_full_masking): Same. (vect_compute_single_scalar_iteration_cost): Same. (vect_analyze_loop_form_1): Same. (vect_analyze_loop_form): Same. (vect_active_double_reduction_p): Same. (vect_analyze_loop_operations): Same. (neutral_op_for_slp_reduction): Same. (vect_is_simple_reduction): Same. (vect_model_reduction_cost): Same. (get_initial_def_for_reduction): Same. (get_initial_defs_for_reduction): Same. (vect_create_epilog_for_reduction): Same. (vectorize_fold_left_reduction): Same. (vectorizable_reduction): Same. (vectorizable_induction): Same. (vectorizable_live_operation): Same. (loop_niters_no_overflow): Same. (vect_get_loop_mask): Same. (vect_transform_loop_stmt): Same. (vect_transform_loop): Same. * tree-vect-patterns.c (vect_reassociating_reduction_p): Same. (vect_determine_precisions): Same. (vect_pattern_recog_1): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. * tree-vect-stmts.c (stmt_vectype): Same. (process_use): Same. (vect_init_vector_1): Same. (vect_truncate_gather_scatter_offset): Same. (get_group_load_store_type): Same. (vect_build_gather_load_calls): Same. (vect_get_strided_load_store_ops): Same. (vectorizable_simd_clone_call): Same. (vectorizable_store): Same. (permute_vec_elements): Same. (vectorizable_load): Same. (vect_transform_stmt): Same. (supportable_widening_operation): Same. * tree-vectorizer.c (vec_info::replace_stmt): Same. (vec_info::free_stmt_vec_info): Same. (vect_free_loop_info_assumptions): Same. (vect_loop_vectorized_call): Same. (set_uid_loop_bbs): Same. (vectorize_loops): Same. * tree-vectorizer.h (STMT_VINFO_BB_VINFO): Same. * tree.c (add_tree_to_fld_list): Same. (fld_type_variant_equal_p): Same. (fld_decl_context): Same. (fld_incomplete_type_of): Same. (free_lang_data_in_binfo): Same. (need_assembler_name_p): Same. (find_decls_types_r): Same. (get_eh_types_for_runtime): Same. (find_decls_types_in_eh_region): Same. (find_decls_types_in_node): Same. (assign_assembler_name_if_needed): Same. * value-prof.c (stream_out_histogram_value): Same. * value-prof.h: Same. * var-tracking.c (use_narrower_mode): Same. (prepare_call_arguments): Same. (vt_expand_loc_callback): Same. (resolve_expansions_pending_recursion): Same. (vt_expand_loc): Same. * varasm.c (const_hash_1): Same. (compare_constant): Same. (tree_output_constant_def): Same. (simplify_subtraction): Same. (get_pool_constant): Same. (output_constant_pool_2): Same. (output_constant_pool_1): Same. (mark_constants_in_pattern): Same. (mark_constant_pool): Same. (get_section_anchor): Same. * vr-values.c (compare_range_with_value): Same. (vr_values::extract_range_from_phi_node): Same. * vr-values.h: Same. * web.c (unionfind_union): Same. * wide-int.h: Same. From-SVN: r273311
2019-07-09 20:32:49 +02:00
class imm_store_chain_info **chain_info = NULL;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bool ret = false;
if (base_addr)
chain_info = m_stores.get (base_addr);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
store_immediate_info *info;
if (chain_info)
{
unsigned int ord = (*chain_info)->m_store_info.length ();
info = new store_immediate_info (const_bitsize, const_bitpos,
const_bitregion_start,
const_bitregion_end,
stmt, ord, rhs_code, n, ins_stmt,
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bit_not_p, lp_nr_for_store (stmt),
ops[0], ops[1]);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Recording immediate store from stmt:\n");
print_gimple_stmt (dump_file, stmt, 0);
}
(*chain_info)->m_store_info.safe_push (info);
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
m_n_stores++;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
ret |= terminate_all_aliasing_chains (chain_info, stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
/* If we reach the limit of stores to merge in a chain terminate and
process the chain now. */
if ((*chain_info)->m_store_info.length ()
Apply mechanical replacement (generated patch). 2019-11-12 Martin Liska <mliska@suse.cz> * asan.c (asan_sanitize_stack_p): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. (asan_sanitize_allocas_p): Likewise. (asan_emit_stack_protection): Likewise. (asan_protect_global): Likewise. (instrument_derefs): Likewise. (instrument_builtin_call): Likewise. (asan_expand_mark_ifn): Likewise. * auto-profile.c (auto_profile): Likewise. * bb-reorder.c (copy_bb_p): Likewise. (duplicate_computed_gotos): Likewise. * builtins.c (inline_expand_builtin_string_cmp): Likewise. * cfgcleanup.c (try_crossjump_to_edge): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.c (defer_stack_allocation): Likewise. (stack_protect_classify_type): Likewise. (pass_expand::execute): Likewise. * cfgloopanal.c (expected_loop_iterations_unbounded): Likewise. (estimate_reg_pressure_cost): Likewise. * cgraph.c (cgraph_edge::maybe_hot_p): Likewise. * combine.c (combine_instructions): Likewise. (record_value_for_reg): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_option_validate_param): Likewise. (aarch64_option_default_params): Likewise. * common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise. * common/config/sh/sh-common.c (sh_option_default_params): Likewise. * config/aarch64/aarch64.c (aarch64_output_probe_stack_range): Likewise. (aarch64_allocate_and_probe_stack_space): Likewise. (aarch64_expand_epilogue): Likewise. (aarch64_override_options_internal): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arm/arm.c (arm_option_override): Likewise. (arm_valid_target_attribute_p): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (get_probe_interval): Likewise. (ix86_adjust_stack_and_probe_stack_clash): Likewise. (ix86_max_noce_ifcvt_seq_cost): Likewise. * config/ia64/ia64.c (ia64_adjust_cost): Likewise. * config/rs6000/rs6000-logue.c (get_stack_clash_protection_probe_interval): Likewise. (get_stack_clash_protection_guard_size): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/s390/s390.c (allocate_stack_space): Likewise. (s390_emit_prologue): Likewise. (s390_option_override_internal): Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/visium/visium.c (visium_option_override): Likewise. * coverage.c (get_coverage_counts): Likewise. (coverage_compute_profile_id): Likewise. (coverage_begin_function): Likewise. (coverage_end_function): Likewise. * cse.c (cse_find_path): Likewise. (cse_extended_basic_block): Likewise. (cse_main): Likewise. * cselib.c (cselib_invalidate_mem): Likewise. * dse.c (dse_step1): Likewise. * emit-rtl.c (set_new_first_and_last_insn): Likewise. (get_max_insn_count): Likewise. (make_debug_insn_raw): Likewise. (init_emit): Likewise. * explow.c (compute_stack_clash_protection_loop_data): Likewise. * final.c (compute_alignments): Likewise. * fold-const.c (fold_range_test): Likewise. (fold_truth_andor): Likewise. (tree_single_nonnegative_warnv_p): Likewise. (integer_valued_real_single_p): Likewise. * gcse.c (want_to_gcse_p): Likewise. (prune_insertions_deletions): Likewise. (hoist_code): Likewise. (gcse_or_cprop_is_too_expensive): Likewise. * ggc-common.c: Likewise. * ggc-page.c (ggc_collect): Likewise. * gimple-loop-interchange.cc (MAX_NUM_STMT): Likewise. (MAX_DATAREFS): Likewise. (OUTER_STRIDE_RATIO): Likewise. * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise. * gimple-loop-versioning.cc (loop_versioning::max_insns_for_loop): Likewise. * gimple-ssa-split-paths.c (is_feasible_trace): Likewise. * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (imm_store_chain_info::output_merged_store): Likewise. (pass_store_merging::process_store): Likewise. * gimple-ssa-strength-reduction.c (find_basis_for_base_expr): Likewise. * graphite-isl-ast-to-gimple.c (class translate_isl_ast_to_gimple): Likewise. (scop_to_isl_ast): Likewise. * graphite-optimize-isl.c (get_schedule_for_node_st): Likewise. (optimize_isl): Likewise. * graphite-scop-detection.c (build_scops): Likewise. * haifa-sched.c (set_modulo_params): Likewise. (rank_for_schedule): Likewise. (model_add_to_worklist): Likewise. (model_promote_insn): Likewise. (model_choose_insn): Likewise. (queue_to_ready): Likewise. (autopref_multipass_dfa_lookahead_guard): Likewise. (schedule_block): Likewise. (sched_init): Likewise. * hsa-gen.c (init_prologue): Likewise. * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Likewise. (cond_move_process_if_block): Likewise. * ipa-cp.c (ipcp_lattice::add_value): Likewise. (merge_agg_lats_step): Likewise. (devirtualization_time_bonus): Likewise. (hint_time_bonus): Likewise. (incorporate_penalties): Likewise. (good_cloning_opportunity_p): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (decompose_param_expr): Likewise. (set_switch_stmt_execution_predicate): Likewise. (analyze_function_body): Likewise. (compute_fn_summary): Likewise. * ipa-inline-analysis.c (estimate_growth): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (inline_insns_single): Likewise. (inline_insns_auto): Likewise. (can_inline_edge_by_limits_p): Likewise. (want_early_inline_function_p): Likewise. (big_speedup_p): Likewise. (want_inline_small_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (edge_badness): Likewise. (recursive_inlining): Likewise. (compute_max_insns): Likewise. (early_inliner): Likewise. * ipa-polymorphic-call.c (csftc_abort_walking_p): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (determine_known_aggregate_parts): Likewise. (ipa_analyze_node): Likewise. (ipcp_transform_function): Likewise. * ipa-split.c (consider_split): Likewise. * ipa-sra.c (allocate_access): Likewise. (process_scan_results): Likewise. (ipa_sra_summarize_function): Likewise. (pull_accesses_from_callee): Likewise. * ira-build.c (loop_compare_func): Likewise. (mark_loops_for_removal): Likewise. * ira-conflicts.c (build_conflict_bit_table): Likewise. * loop-doloop.c (doloop_optimize): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. (move_loop_invariants): Likewise. * loop-unroll.c (decide_unroll_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. (expand_var_during_unrolling): Likewise. * lra-assigns.c (spill_for): Likewise. * lra-constraints.c (EBB_PROBABILITY_CUTOFF): Likewise. * modulo-sched.c (sms_schedule): Likewise. (DFA_HISTORY): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (common_handle_option): Likewise. * postreload-gcse.c (eliminate_partially_redundant_load): Likewise. (if): Likewise. * predict.c (get_hot_bb_threshold): Likewise. (maybe_hot_count_p): Likewise. (probably_never_executed): Likewise. (predictable_edge_p): Likewise. (predict_loops): Likewise. (expr_expected_value_1): Likewise. (tree_predict_by_opcode): Likewise. (handle_missing_profiles): Likewise. * reload.c (find_equiv_reg): Likewise. * reorg.c (redundant_insn): Likewise. * resource.c (mark_target_live_regs): Likewise. (incr_ticks_for_insn): Likewise. * sanopt.c (pass_sanopt::execute): Likewise. * sched-deps.c (sched_analyze_1): Likewise. (sched_analyze_2): Likewise. (sched_analyze_insn): Likewise. (deps_analyze_insn): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (find_single_block_region): Likewise. (too_large): Likewise. (haifa_find_rgns): Likewise. (extend_rgns): Likewise. (new_ready): Likewise. (schedule_region): Likewise. (sched_rgn_init): Likewise. * sel-sched-ir.c (make_region_from_loop): Likewise. * sel-sched-ir.h (MAX_WS): Likewise. * sel-sched.c (process_pipelined_exprs): Likewise. (sel_setup_region_sched_flags): Likewise. * shrink-wrap.c (try_shrink_wrapping): Likewise. * targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise. * toplev.c (print_version): Likewise. (process_options): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_log_add): Likewise. * tree-chrec.c (chrec_fold_plus_1): Likewise. * tree-data-ref.c (split_constant_offset): Likewise. (compute_all_dependences): Likewise. * tree-if-conv.c (MAX_PHI_ARG_NUM): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. * tree-loop-distribution.c (MAX_DATAREFS_NUM): Likewise. * tree-parloops.c (MIN_PER_THREAD): Likewise. (create_parallel_loop): Likewise. * tree-predcom.c (determine_unroll_factor): Likewise. * tree-scalar-evolution.c (instantiate_scev_r): Likewise. * tree-sra.c (analyze_all_variable_accesses): Likewise. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Likewise. * tree-ssa-dse.c (setup_live_bytes_from_ref): Likewise. (dse_optimize_redundant_stores): Likewise. (dse_classify_store): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise. * tree-ssa-loop-im.c (LIM_EXPENSIVE): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise. (CONSIDER_ALL_CANDIDATES_BOUND): Likewise. (MAX_CONSIDERED_GROUPS): Likewise. (ALWAYS_PRUNE_CAND_SET_BOUND): Likewise. * tree-ssa-loop-manip.c (can_unroll_loop_p): Likewise. * tree-ssa-loop-niter.c (MAX_ITERATIONS_TO_TRACK): Likewise. * tree-ssa-loop-prefetch.c (PREFETCH_BLOCK): Likewise. (L1_CACHE_SIZE_BYTES): Likewise. (L2_CACHE_SIZE_BYTES): Likewise. (should_issue_prefetch_p): Likewise. (schedule_prefetches): Likewise. (determine_unroll_factor): Likewise. (volume_of_references): Likewise. (add_subscript_strides): Likewise. (self_reuse_distance): Likewise. (mem_ref_count_reasonable_p): Likewise. (insn_to_prefetch_ratio_too_small_p): Likewise. (loop_prefetch_arrays): Likewise. (tree_ssa_prefetch_arrays): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. (convert_mult_to_fma): Likewise. (math_opts_dom_walker::after_dom_children): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. (hoist_adjacent_loads): Likewise. (gate_hoist_loads): Likewise. * tree-ssa-pre.c (translate_vuse_through_block): Likewise. (compute_partial_antic_aux): Likewise. * tree-ssa-reassoc.c (get_reassociation_width): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. (do_rpo_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. * tree-ssa-sink.c (select_best_block): Likewise. * tree-ssa-strlen.c (new_stridx): Likewise. (new_addr_stridx): Likewise. (get_range_strlen_dynamic): Likewise. (class ssa_name_limit_t): Likewise. * tree-ssa-structalias.c (push_fields_onto_fieldstack): Likewise. (create_variable_info_for_1): Likewise. (init_alias_vars): Likewise. * tree-ssa-tail-merge.c (find_clusters_1): Likewise. (tail_merge_optimize): Likewise. * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Likewise. (thread_jumps::fsm_find_control_statement_thread_paths): Likewise. (thread_jumps::find_jump_threads_backwards): Likewise. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Likewise. * tree-ssa-uninit.c (compute_control_dep_chain): Likewise. * tree-switch-conversion.c (switch_conversion::check_range): Likewise. (jump_table_cluster::can_be_handled): Likewise. * tree-switch-conversion.h (jump_table_cluster::case_values_threshold): Likewise. (SWITCH_CONVERSION_BRANCH_RATIO): Likewise. (param_switch_conversion_branch_ratio): Likewise. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_analyze_loop_costing): Likewise. (vect_get_datarefs_in_loop): Likewise. (vect_analyze_loop): Likewise. * tree-vect-slp.c (vect_slp_bb): Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (vrp_prop::check_mem_ref): Likewise. * tree.c (wide_int_to_tree_1): Likewise. (cache_integer_cst): Likewise. * var-tracking.c (EXPR_USE_DEPTH): Likewise. (reverse_op): Likewise. (vt_find_locations): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_parse_gimple_body): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_hints::namespace_hints): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * typeck.c (comptypes): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-partition.c (lto_balanced_map): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * lto.c (do_whole_program_analysis): Likewise. From-SVN: r278085
2019-11-12 11:08:40 +01:00
== (unsigned int) param_max_stores_to_merge)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
"Reached maximum number of statements to merge:\n");
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
ret |= terminate_and_process_chain (*chain_info);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
}
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
else
{
/* Store aliases any existing chain? */
ret |= terminate_all_aliasing_chains (NULL, stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
/* Start a new chain. */
class imm_store_chain_info *new_chain
= new imm_store_chain_info (m_stores_head, base_addr);
info = new store_immediate_info (const_bitsize, const_bitpos,
const_bitregion_start,
const_bitregion_end,
stmt, 0, rhs_code, n, ins_stmt,
bit_not_p, lp_nr_for_store (stmt),
ops[0], ops[1]);
new_chain->m_store_info.safe_push (info);
m_n_stores++;
m_stores.put (base_addr, new_chain);
m_n_chains++;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Starting active chain number %u with statement:\n",
m_n_chains);
print_gimple_stmt (dump_file, stmt, 0);
fprintf (dump_file, "The base object is:\n");
print_generic_expr (dump_file, base_addr);
fprintf (dump_file, "\n");
}
}
/* Prune oldest chains so that after adding the chain or store above
we're again within the limits set by the params. */
if (m_n_chains > (unsigned)param_max_store_chains_to_track
|| m_n_stores > (unsigned)param_max_stores_to_track)
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
{
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Too many chains (%u > %d) or stores (%u > %d), "
"terminating oldest chain(s).\n", m_n_chains,
param_max_store_chains_to_track, m_n_stores,
param_max_stores_to_track);
imm_store_chain_info **e = &m_stores_head;
unsigned idx = 0;
unsigned n_stores = 0;
while (*e)
{
if (idx >= (unsigned)param_max_store_chains_to_track
|| (n_stores + (*e)->m_store_info.length ()
> (unsigned)param_max_stores_to_track))
ret |= terminate_and_process_chain (*e);
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
else
{
n_stores += (*e)->m_store_info.length ();
e = &(*e)->next;
++idx;
}
}
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
tree-optimization/38474 - fix store-merging compile-time regression The following puts a limit on the number of alias tests we do in terminate_all_aliasing_chains which is quadratic in the number of overall stores currentrly tracked. There is already a limit in place on the maximum number of stores in a single chain so the following adds a limit on the number of chains tracked. The worst number of overall stores tracked from the defaults (64 and 64) is then 4096 which when imposed as the sole limit for the testcase still causes store merging : 71.65 ( 56%) because the testcase is somewhat degenerate with most chains consisting only of a single store (and 25% of exactly three stores). The single stores are all CLOBBERs at the point variables go out of scope. Note unpatched we have store merging : 308.60 ( 84%) Limiting the number of chains to 64 brings this down to store merging : 1.52 ( 3%) which is more reasonable. There are ideas on how to make terminate_all_aliasing_chains cheaper but for this degenerate case they would not have any effect so I'll defer for GCC 12 for those. I'm not sure we want to have both --params, just keeping the more to-the-point max-stores-to-track works but makes the degenerate case above slower. I made the current default 1024 which for the testcasse (without limiting chains) results in 25% compile time and 20s putting it in the same ballpart as the next offender (which is PTA). This is a regression on trunk and the GCC 10 branch btw. 2021-02-11 Richard Biener <rguenther@suse.de> PR tree-optimization/38474 * params.opt (-param=max-store-chains-to-track=): New param. (-param=max-stores-to-track=): Likewise. * doc/invoke.texi (max-store-chains-to-track): Document. (max-stores-to-track): Likewise. * gimple-ssa-store-merging.c (pass_store_merging::m_n_chains): New. (pass_store_merging::m_n_stores): Likewise. (pass_store_merging::terminate_and_process_chain): Update m_n_stores and m_n_chains. (pass_store_merging::process_store): Likewise. Terminate oldest chains if the number of stores or chains get too large. (imm_store_chain_info::terminate_and_process_chain): Dump chain length.
2021-02-11 11:13:47 +01:00
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
return ret;
}
/* Return true if STMT is a store valid for store merging. */
static bool
store_valid_for_store_merging_p (gimple *stmt)
{
return gimple_assign_single_p (stmt)
&& gimple_vdef (stmt)
&& lhs_valid_for_store_merging_p (gimple_assign_lhs (stmt))
&& (!gimple_has_volatile_ops (stmt) || gimple_clobber_p (stmt));
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
}
enum basic_block_status { BB_INVALID, BB_VALID, BB_EXTENDED_VALID };
/* Return the status of basic block BB wrt store merging. */
static enum basic_block_status
get_status_for_store_merging (basic_block bb)
{
unsigned int num_statements = 0;
unsigned int num_constructors = 0;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
gimple_stmt_iterator gsi;
edge e;
gimple *last_stmt = NULL;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
continue;
last_stmt = stmt;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (store_valid_for_store_merging_p (stmt) && ++num_statements >= 2)
break;
if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == CONSTRUCTOR)
{
tree rhs = gimple_assign_rhs1 (stmt);
if (VECTOR_TYPE_P (TREE_TYPE (rhs))
&& INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (rhs)))
&& gimple_assign_lhs (stmt) != NULL_TREE)
{
HOST_WIDE_INT sz
= int_size_in_bytes (TREE_TYPE (rhs)) * BITS_PER_UNIT;
if (sz == 16 || sz == 32 || sz == 64)
{
num_constructors = 1;
break;
}
}
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
}
if (num_statements == 0 && num_constructors == 0)
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
return BB_INVALID;
if (cfun->can_throw_non_call_exceptions && cfun->eh
&& store_valid_for_store_merging_p (last_stmt)
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
&& (e = find_fallthru_edge (bb->succs))
&& e->dest == bb->next_bb)
return BB_EXTENDED_VALID;
return (num_statements >= 2 || num_constructors) ? BB_VALID : BB_INVALID;
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
/* Entry point for the pass. Go over each basic block recording chains of
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
immediate stores. Upon encountering a terminating statement (as defined
by stmt_terminates_chain_p) process the recorded stores and emit the widened
variants. */
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
unsigned int
pass_store_merging::execute (function *fun)
{
basic_block bb;
hash_set<gimple *> orig_stmts;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
bool changed = false, open_chains = false;
/* If the function can throw and catch non-call exceptions, we'll be trying
to merge stores across different basic blocks so we need to first unsplit
the EH edges in order to streamline the CFG of the function. */
if (cfun->can_throw_non_call_exceptions && cfun->eh)
unsplit_eh_edges ();
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Give up if base is TARGET_MEM_REF. If base is not MEM_REF, set base_addr to the address of the base rather than the base itself. (find_bswap_or_nop_1): Just use pointer comparison for vuse check. (find_bswap_or_nop_finalize): New function. (find_bswap_or_nop): Use it. (bswap_replace): Return a tree rather than bool, change first argument from gimple * to gimple_stmt_iterator, allow inserting into an empty sequence, allow ins_stmt to be NULL - then emit all stmts into gsi. Fix up MEM_REF address gimplification. (pass_optimize_bswap::execute): Adjust bswap_replace caller. (struct store_immediate_info): Add N and INS_STMT non-static data members. (store_immediate_info::store_immediate_info): Initialize them from newly added ctor args. (merged_store_group::apply_stores): Formatting fixes. Sort by bitpos at the end. (stmts_may_clobber_ref_p): For stores call also refs_anti_dependent_p. (gather_bswap_load_refs): New function. (imm_store_chain_info::try_coalesce_bswap): New method. (imm_store_chain_info::coalesce_immediate_stores): Use it. (split_group): Handle LROTATE_EXPR and NOP_EXPR rhs_code specially. (imm_store_chain_info::output_merged_store): Fail if number of new estimated stmts is bigger or equal than old. Handle LROTATE_EXPR and NOP_EXPR rhs_code. (pass_store_merging::process_store): Compute n and ins_stmt, if ins_stmt is non-NULL and the store rhs is otherwise invalid, use LROTATE_EXPR rhs_code. Pass n and ins_stmt to store_immediate_info ctor. (pass_store_merging::execute): Calculate dominators. * gcc.dg/store_merging_16.c: New test. From-SVN: r254948
2017-11-20 11:10:23 +01:00
calculate_dominance_info (CDI_DOMINATORS);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
FOR_EACH_BB_FN (bb, fun)
{
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
const basic_block_status bb_status = get_status_for_store_merging (bb);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
gimple_stmt_iterator gsi;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (open_chains && (bb_status == BB_INVALID || !single_pred_p (bb)))
{
changed |= terminate_and_process_all_chains ();
open_chains = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (bb_status == BB_INVALID)
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
continue;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Processing basic block <%d>:\n", bb->index);
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); )
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
gimple *stmt = gsi_stmt (gsi);
gsi_next (&gsi);
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
if (is_gimple_debug (stmt))
continue;
if (gimple_has_volatile_ops (stmt) && !gimple_clobber_p (stmt))
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
{
/* Terminate all chains. */
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Volatile access terminates "
"all chains\n");
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
changed |= terminate_and_process_all_chains ();
open_chains = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
continue;
}
if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == CONSTRUCTOR
&& maybe_optimize_vector_constructor (stmt))
continue;
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (store_valid_for_store_merging_p (stmt))
changed |= process_store (stmt);
re PR tree-optimization/78821 (GCC7: Copying whole 32 bits structure field by field not optimised into copying whole 32 bits at once) PR tree-optimization/78821 * gimple-ssa-store-merging.c: Update the file comment. (MAX_STORE_ALIAS_CHECKS): Define. (struct store_operand_info): New type. (store_operand_info::store_operand_info): New constructor. (struct store_immediate_info): Add rhs_code and ops data members. (store_immediate_info::store_immediate_info): Add rhscode, op0r and op1r arguments to the ctor, initialize corresponding data members. (struct merged_store_group): Add load_align_base and load_align data members. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::do_merge): Update them. (merged_store_group::apply_stores): Pick the constant for encode_tree_to_bitpos from one of the two operands, or skip encode_tree_to_bitpos if neither operand is a constant. (class pass_store_merging): Add process_store method decl. Remove bool argument from terminate_all_aliasing_chains method decl. (pass_store_merging::terminate_all_aliasing_chains): Remove var_offset_p argument and corresponding handling. (stmts_may_clobber_ref_p): New function. (compatible_load_p): New function. (imm_store_chain_info::coalesce_immediate_stores): Terminate group if there is overlap and rhs_code is not INTEGER_CST. For non-overlapping stores terminate group if rhs is not mergeable. (get_alias_type_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. Add IS_LOAD, CLIQUEP and BASEP arguments. If IS_LOAD is true, look at rhs1 of the stmts instead of lhs. Compute *CLIQUEP and *BASEP in addition to the alias type. (get_location_for_stmts): Change first argument from auto_vec<gimple *> & to vec<gimple *> &. (struct split_store): Remove orig_stmts data member, add orig_stores. (split_store::split_store): Create orig_stores rather than orig_stmts. (find_constituent_stmts): Renamed to ... (find_constituent_stores): ... this. Change second argument from vec<gimple *> * to vec<store_immediate_info *> *, push pointers to info structures rather than the statements. (split_group): Rename ALLOW_UNALIGNED argument to ALLOW_UNALIGNED_STORE, add ALLOW_UNALIGNED_LOAD argument and handle it. Adjust find_constituent_stores caller. (imm_store_chain_info::output_merged_store): Handle rhs_code other than INTEGER_CST, adjust split_group, get_alias_type_for_stmts and get_location_for_stmts callers. Set MR_DEPENDENCE_CLIQUE and MR_DEPENDENCE_BASE on the MEM_REFs if they are the same in all stores. (mem_valid_for_store_merging): New function. (handled_load): New function. (pass_store_merging::process_store): New method. (pass_store_merging::execute): Use process_store method. Adjust terminate_all_aliasing_chains caller. * gcc.dg/store_merging_13.c: New test. * gcc.dg/store_merging_14.c: New test. From-SVN: r254391
2017-11-03 20:08:25 +01:00
else
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
changed |= terminate_all_aliasing_chains (NULL, stmt);
}
if (bb_status == BB_EXTENDED_VALID)
open_chains = true;
else
{
changed |= terminate_and_process_all_chains ();
open_chains = false;
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
}
}
tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-10-02 15:35:40 +02:00
if (open_chains)
changed |= terminate_and_process_all_chains ();
/* If the function can throw and catch non-call exceptions and something
changed during the pass, then the CFG has (very likely) changed too. */
if (cfun->can_throw_non_call_exceptions && cfun->eh && changed)
{
free_dominance_info (CDI_DOMINATORS);
return TODO_cleanup_cfg;
}
GIMPLE store merging pass 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR middle-end/22141 * Makefile.in (OBJS): Add gimple-ssa-store-merging.o. * common.opt (fstore-merging): New Optimization option. * opts.c (default_options_table): Add entry for OPT_ftree_store_merging. * fold-const.h (can_native_encode_type_p): Declare prototype. * fold-const.c (can_native_encode_type_p): Define. * params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define. (PARAM_MAX_STORES_TO_MERGE): Likewise. * timevar.def (TV_GIMPLE_STORE_MERGING): New timevar. * passes.def: Insert pass_tree_store_merging. * tree-pass.h (make_pass_store_merging): Declare extern prototype. * gimple-ssa-store-merging.c: New file. * doc/invoke.texi (Optimization Options): Document -fstore-merging. (--param documentation): Document store-merging-allow-unaligned and max-stores-to-merge. 2016-10-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> Jakub Jelinek <jakub@redhat.com> Andrew Pinski <pinskia@gmail.com> PR middle-end/22141 PR rtl-optimization/23684 * gcc.c-torture/execute/pr22141-1.c: New test. * gcc.c-torture/execute/pr22141-2.c: Likewise. * gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging. * gcc.target/aarch64/ldp_stp_4.c: Likewise. * gcc.dg/store_merging_1.c: New test. * gcc.dg/store_merging_2.c: Likewise. * gcc.dg/store_merging_3.c: Likewise. * gcc.dg/store_merging_4.c: Likewise. * gcc.dg/store_merging_5.c: Likewise. * gcc.dg/store_merging_6.c: Likewise. * gcc.dg/store_merging_7.c: Likewise. * gcc.target/i386/pr22141.c: Likewise. * gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options. * g++.dg/init/new17.C: Likewise. Co-Authored-By: Andrew Pinski <pinskia@gmail.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r241649
2016-10-28 16:18:50 +02:00
return 0;
}
} // anon namespace
/* Construct and return a store merging pass object. */
gimple_opt_pass *
make_pass_store_merging (gcc::context *ctxt)
{
return new pass_store_merging (ctxt);
}
#if CHECKING_P
namespace selftest {
/* Selftests for store merging helpers. */
/* Assert that all elements of the byte arrays X and Y, both of length N
are equal. */
static void
verify_array_eq (unsigned char *x, unsigned char *y, unsigned int n)
{
for (unsigned int i = 0; i < n; i++)
{
if (x[i] != y[i])
{
fprintf (stderr, "Arrays do not match. X:\n");
dump_char_array (stderr, x, n);
fprintf (stderr, "Y:\n");
dump_char_array (stderr, y, n);
}
ASSERT_EQ (x[i], y[i]);
}
}
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
/* Test shift_bytes_in_array_left and that it carries bits across between
bytes correctly. */
static void
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
verify_shift_bytes_in_array_left (void)
{
/* byte 1 | byte 0
00011111 | 11100000. */
unsigned char orig[2] = { 0xe0, 0x1f };
unsigned char in[2];
memcpy (in, orig, sizeof orig);
unsigned char expected[2] = { 0x80, 0x7f };
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
shift_bytes_in_array_left (in, sizeof (in), 2);
verify_array_eq (in, expected, sizeof (in));
memcpy (in, orig, sizeof orig);
memcpy (expected, orig, sizeof orig);
/* Check that shifting by zero doesn't change anything. */
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
shift_bytes_in_array_left (in, sizeof (in), 0);
verify_array_eq (in, expected, sizeof (in));
}
/* Test shift_bytes_in_array_right and that it carries bits across between
bytes correctly. */
static void
verify_shift_bytes_in_array_right (void)
{
/* byte 1 | byte 0
00011111 | 11100000. */
unsigned char orig[2] = { 0x1f, 0xe0};
unsigned char in[2];
memcpy (in, orig, sizeof orig);
unsigned char expected[2] = { 0x07, 0xf8};
shift_bytes_in_array_right (in, sizeof (in), 2);
verify_array_eq (in, expected, sizeof (in));
memcpy (in, orig, sizeof orig);
memcpy (expected, orig, sizeof orig);
/* Check that shifting by zero doesn't change anything. */
shift_bytes_in_array_right (in, sizeof (in), 0);
verify_array_eq (in, expected, sizeof (in));
}
/* Test clear_bit_region that it clears exactly the bits asked and
nothing more. */
static void
verify_clear_bit_region (void)
{
/* Start with all bits set and test clearing various patterns in them. */
unsigned char orig[3] = { 0xff, 0xff, 0xff};
unsigned char in[3];
unsigned char expected[3];
memcpy (in, orig, sizeof in);
/* Check zeroing out all the bits. */
clear_bit_region (in, 0, 3 * BITS_PER_UNIT);
expected[0] = expected[1] = expected[2] = 0;
verify_array_eq (in, expected, sizeof in);
memcpy (in, orig, sizeof in);
/* Leave the first and last bits intact. */
clear_bit_region (in, 1, 3 * BITS_PER_UNIT - 2);
expected[0] = 0x1;
expected[1] = 0;
expected[2] = 0x80;
verify_array_eq (in, expected, sizeof in);
}
/* Test clear_bit_region_be that it clears exactly the bits asked and
nothing more. */
static void
verify_clear_bit_region_be (void)
{
/* Start with all bits set and test clearing various patterns in them. */
unsigned char orig[3] = { 0xff, 0xff, 0xff};
unsigned char in[3];
unsigned char expected[3];
memcpy (in, orig, sizeof in);
/* Check zeroing out all the bits. */
clear_bit_region_be (in, BITS_PER_UNIT - 1, 3 * BITS_PER_UNIT);
expected[0] = expected[1] = expected[2] = 0;
verify_array_eq (in, expected, sizeof in);
memcpy (in, orig, sizeof in);
/* Leave the first and last bits intact. */
clear_bit_region_be (in, BITS_PER_UNIT - 2, 3 * BITS_PER_UNIT - 2);
expected[0] = 0x80;
expected[1] = 0;
expected[2] = 0x1;
verify_array_eq (in, expected, sizeof in);
}
/* Run all of the selftests within this file. */
void
Update per-file selftest and finalization hooks for .c to .cc renaming This is mostly a mechanical change, apart from: - fix the name of attribute_c_tests to match its filename (attribs.cc) - fix the name of opt_proposer_c to match its filename (opt-suggestions.cc) - delete a bogus "modref_c_tests" decl from ipa-modref-tree.h that's been present since the initial commit of that file (d119f34c952f8718fdbabc63e2f369a16e92fa07) gcc/ChangeLog: * attribs.cc (attribute_c_tests): Rename to... (attribs_cc_tests): ...this. * bitmap.cc (bitmap_c_tests): Rename to... (bitmap_cc_tests): ...this. * cgraph.cc (cgraph_c_finalize): Rename to... (cgraph_cc_finalize): ...this. (cgraph_c_tests): Rename to... (cgraph_cc_tests): ...this. * cgraph.h (cgraph_c_finalize): Rename to... (cgraph_cc_finalize): ...this. (cgraphunit_c_finalize): Rename to... (cgraphunit_cc_finalize): ...this. * cgraphunit.cc (cgraphunit_c_finalize): Rename to... (cgraphunit_cc_finalize): ...this. * convert.cc (convert_c_tests): Rename to... (convert_cc_tests): ...this. * dbgcnt.cc (dbgcnt_c_tests): Rename to... (dbgcnt_cc_tests): ...this. * diagnostic-show-locus.cc (diagnostic_show_locus_c_tests): Rename to... (diagnostic_show_locus_cc_tests): ...this. * diagnostic.cc (diagnostic_c_tests): Rename to... (diagnostic_cc_tests): ...this. * dumpfile.cc (dumpfile_c_tests): Rename to... (dumpfile_cc_tests): ...this. * dwarf2out.cc (dwarf2out_c_finalize): Rename to... (dwarf2out_cc_finalize): ...this. * dwarf2out.h (dwarf2out_c_finalize): Rename to... (dwarf2out_cc_finalize): ...this. * edit-context.cc (edit_context_c_tests): Rename to... (edit_context_cc_tests): ...this. * et-forest.cc (et_forest_c_tests): Rename to... (et_forest_cc_tests): ...this. * fibonacci_heap.cc (fibonacci_heap_c_tests): Rename to... (fibonacci_heap_cc_tests): ...this. * fold-const.cc (fold_const_c_tests): Rename to... (fold_const_cc_tests): ...this. * function-tests.cc (function_tests_c_tests): Rename to... (function_tests_cc_tests): ...this. * gcse.cc (gcse_c_finalize): Rename to... (gcse_cc_finalize): ...this. * gcse.h (gcse_c_finalize): Rename to... (gcse_cc_finalize): ...this. * ggc-tests.cc (ggc_tests_c_tests): Rename to... (ggc_tests_cc_tests): ...this. * gimple-ssa-store-merging.cc (store_merging_c_tests): Rename to... (store_merging_cc_tests): ...this. * gimple.cc (gimple_c_tests): Rename to... (gimple_cc_tests): ...this. * hash-map-tests.cc (hash_map_tests_c_tests): Rename to... (hash_map_tests_cc_tests): ...this. * hash-set-tests.cc (hash_set_tests_c_tests): Rename to... (hash_set_tests_cc_tests): ...this. * input.cc (input_c_tests): Rename to... (input_cc_tests): ...this. * ipa-cp.cc (ipa_cp_c_finalize): Rename to... (ipa_cp_cc_finalize): ...this. * ipa-fnsummary.cc (ipa_fnsummary_c_finalize): Rename to... (ipa_fnsummary_cc_finalize): ...this. * ipa-fnsummary.h (ipa_fnsummary_c_finalize): Rename to... (ipa_fnsummary_cc_finalize): ...this. * ipa-modref-tree.cc (ipa_modref_tree_c_tests): Rename to... (ipa_modref_tree_cc_tests): ...this. * ipa-modref-tree.h (modref_c_tests): Delete bogus decl. * ipa-modref.cc (ipa_modref_c_finalize): Rename to... (ipa_modref_cc_finalize): ...this. * ipa-modref.h (ipa_modref_c_finalize): Rename to... (ipa_modref_cc_finalize): ...this. * ipa-prop.h (ipa_cp_c_finalize): Rename to... (ipa_cp_cc_finalize): ...this. * ipa-reference.cc (ipa_reference_c_finalize): Rename to... (ipa_reference_cc_finalize): ...this. * ipa-reference.h (ipa_reference_c_finalize): Rename to... (ipa_reference_cc_finalize): ...this. * ira-costs.cc (ira_costs_c_finalize): Rename to... (ira_costs_cc_finalize): ...this. * ira.h (ira_costs_c_finalize): Rename to... (ira_costs_cc_finalize): ...this. * opt-suggestions.cc (opt_proposer_c_tests): Rename to... (opt_suggestions_cc_tests): ...this. * opts.cc (opts_c_tests): Rename to... (opts_cc_tests): ...this. * predict.cc (predict_c_tests): Rename to... (predict_cc_tests): ...this. * pretty-print.cc (pretty_print_c_tests): Rename to... (pretty_print_cc_tests): ...this. * read-rtl-function.cc (read_rtl_function_c_tests): Rename to... (read_rtl_function_cc_tests): ...this. * rtl-tests.cc (rtl_tests_c_tests): Rename to... (rtl_tests_cc_tests): ...this. * sbitmap.cc (sbitmap_c_tests): Rename to... (sbitmap_cc_tests): ...this. * selftest-run-tests.cc (selftest::run_tests): Update calls for _c_ to _cc_ function renamings; fix names of attribs and opt-suggestions tests. * selftest.cc (selftest_c_tests): Rename to... (selftest_cc_tests): ...this. * selftest.h (attribute_c_tests): Rename to... (attribs_cc_tests): ...this. (bitmap_c_tests): Rename to... (bitmap_cc_tests): ...this. (cgraph_c_tests): Rename to... (cgraph_cc_tests): ...this. (convert_c_tests): Rename to... (convert_cc_tests): ...this. (diagnostic_c_tests): Rename to... (diagnostic_cc_tests): ...this. (diagnostic_show_locus_c_tests): Rename to... (diagnostic_show_locus_cc_tests): ...this. (dumpfile_c_tests): Rename to... (dumpfile_cc_tests): ...this. (edit_context_c_tests): Rename to... (edit_context_cc_tests): ...this. (et_forest_c_tests): Rename to... (et_forest_cc_tests): ...this. (fibonacci_heap_c_tests): Rename to... (fibonacci_heap_cc_tests): ...this. (fold_const_c_tests): Rename to... (fold_const_cc_tests): ...this. (function_tests_c_tests): Rename to... (function_tests_cc_tests): ...this. (ggc_tests_c_tests): Rename to... (ggc_tests_cc_tests): ...this. (gimple_c_tests): Rename to... (gimple_cc_tests): ...this. (hash_map_tests_c_tests): Rename to... (hash_map_tests_cc_tests): ...this. (hash_set_tests_c_tests): Rename to... (hash_set_tests_cc_tests): ...this. (input_c_tests): Rename to... (input_cc_tests): ...this. (opts_c_tests): Rename to... (opts_cc_tests): ...this. (predict_c_tests): Rename to... (predict_cc_tests): ...this. (pretty_print_c_tests): Rename to... (pretty_print_cc_tests): ...this. (read_rtl_function_c_tests): Rename to... (read_rtl_function_cc_tests): ...this. (rtl_tests_c_tests): Rename to... (rtl_tests_cc_tests): ...this. (sbitmap_c_tests): Rename to... (sbitmap_cc_tests): ...this. (selftest_c_tests): Rename to... (selftest_cc_tests): ...this. (simplify_rtx_c_tests): Rename to... (simplify_rtx_cc_tests): ...this. (spellcheck_c_tests): Rename to... (spellcheck_cc_tests): ...this. (spellcheck_tree_c_tests): Rename to... (spellcheck_tree_cc_tests): ...this. (sreal_c_tests): Rename to... (sreal_cc_tests): ...this. (store_merging_c_tests): Rename to... (store_merging_cc_tests): ...this. (tree_c_tests): Rename to... (tree_cc_tests): ...this. (tree_cfg_c_tests): Rename to... (tree_cfg_cc_tests): ...this. (typed_splay_tree_c_tests): Rename to... (typed_splay_tree_cc_tests): ...this. (vec_c_tests): Rename to... (vec_cc_tests): ...this. (vec_perm_indices_c_tests): Rename to... (vec_perm_indices_cc_tests): ..this. (opt_proposer_c_tests): Rename to... (opt_suggestions_cc_tests): ...this. (dbgcnt_c_tests): Rename to... (dbgcnt_cc_tests): ...this. (ipa_modref_tree_c_tests): Rename to... (ipa_modref_tree_cc_tests): ...this. * simplify-rtx.cc (simplify_rtx_c_tests): Rename to... (simplify_rtx_cc_tests): ...this. * spellcheck-tree.cc (spellcheck_tree_c_tests): Rename to... (spellcheck_tree_cc_tests): ...this. * spellcheck.cc (spellcheck_c_tests): Rename to... (spellcheck_cc_tests): ...this. * sreal.cc (sreal_c_tests): Rename to... (sreal_cc_tests): ...this. * toplev.cc (toplev::finalize): Update calls for _c_ to _cc_ function renamings. * tree-cfg.cc (tree_cfg_c_tests): Rename to... (tree_cfg_cc_tests): ...this. * tree.cc (tree_c_tests): Rename to... (tree_cc_tests): ...this. * typed-splay-tree.cc (typed_splay_tree_c_tests): Rename to... (typed_splay_tree_cc_tests): ...this. * vec-perm-indices.cc (vec_perm_indices_c_tests): Rename to... (vec_perm_indices_cc_tests): ...this. * vec.cc (vec_c_tests): Rename to... (vec_cc_tests): ...this. gcc/c-family/ChangeLog: * c-common.cc (c_common_c_tests): Rename to... (c_common_cc_tests): ...this. (c_family_tests): Update calls for .c to .cc renaming. * c-common.h (c_format_c_tests): Rename to... (c_format_cc_tests): ...this. (c_indentation_c_tests): Rename to... (c_indentation_cc_tests): ...this. (c_pretty_print_c_tests): Rename to... (c_pretty_print_cc_tests): ...this. * c-format.cc (c_format_c_tests): Rename to... (c_format_cc_tests): ...this. * c-indentation.cc (c_indentation_c_tests): Rename to... (c_indentation_cc_tests): ...this. * c-pretty-print.cc (c_pretty_print_c_tests): Rename to... (c_pretty_print_cc_tests): ...this. gcc/cp/ChangeLog: * cp-lang.cc (selftest::run_cp_tests): Update calls for .c to .cc renaming. * cp-tree.h (cp_pt_c_tests): Rename to... (cp_pt_cc_tests): ...this. (cp_tree_c_tests): Rename to... (cp_tree_cc_tests): ...this. * pt.cc (cp_pt_c_tests): Rename to... (cp_pt_cc_tests): ...this. * tree.cc (cp_tree_c_tests): Rename to... (cp_tree_cc_tests): ...this. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-18 20:36:27 +01:00
store_merging_cc_tests (void)
{
sccvn: Handle bitfields in vn_reference_lookup_3 [PR93582] The following patch is first step towards fixing PR93582. vn_reference_lookup_3 right now punts on anything that isn't byte aligned, so to be able to lookup a constant bitfield store, one needs to use the exact same COMPONENT_REF, otherwise it isn't found. This patch lifts up that that restriction if the bits to be loaded are covered by a single store of a constant (keeps the restriction so far for the multiple store case, can tweak that incrementally, but I think for bisection etc. it is worth to do it one step at a time). 2020-02-13 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/93582 * fold-const.h (shift_bytes_in_array_left, shift_bytes_in_array_right): Declare. * fold-const.c (shift_bytes_in_array_left, shift_bytes_in_array_right): New function, moved from gimple-ssa-store-merging.c, no longer static. * gimple-ssa-store-merging.c (shift_bytes_in_array): Move to gimple-ssa-store-merging.c and rename to shift_bytes_in_array_left. (shift_bytes_in_array_right): Move to gimple-ssa-store-merging.c. (encode_tree_to_bitpos): Use shift_bytes_in_array_left instead of shift_bytes_in_array. (verify_shift_bytes_in_array): Rename to ... (verify_shift_bytes_in_array_left): ... this. Use shift_bytes_in_array_left instead of shift_bytes_in_array. (store_merging_c_tests): Call verify_shift_bytes_in_array_left instead of verify_shift_bytes_in_array. * tree-ssa-sccvn.c (vn_reference_lookup_3): For native_encode_expr / native_interpret_expr where the store covers all needed bits, punt on PDP-endian, otherwise allow all involved offsets and sizes not to be byte-aligned. * gcc.dg/tree-ssa/pr93582-1.c: New test. * gcc.dg/tree-ssa/pr93582-2.c: New test. * gcc.dg/tree-ssa/pr93582-3.c: New test.
2020-02-13 10:04:11 +01:00
verify_shift_bytes_in_array_left ();
verify_shift_bytes_in_array_right ();
verify_clear_bit_region ();
verify_clear_bit_region_be ();
}
} // namespace selftest
#endif /* CHECKING_P. */