aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-data-refs.c
AgeCommit message (Collapse)AuthorFilesLines
2019-04-09SVE fallout from PR90006Richard Sandiford1-7/+22
2019-04-08 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Always use gimple_expr_type for load and store calls. Skip over the condition argument in a conditional internal function. Protect use of TREE_INT_CST_LOW. From-SVN: r270222
2019-04-08re PR tree-optimization/90006 (gcc loops indefinitely around ↵Richard Biener1-0/+9
vect_get_constant_vectors on -O2 -ftree-slp-vectorize -fno-math-errno) 2019-04-08 Richard Biener <rguenther@suse.de> PR tree-optimization/90006 * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Handle calls like lrint. * gcc.dg/vect/bb-slp-pr90006.c: New testcase. From-SVN: r270210
2019-03-26re PR tree-optimization/81740 (wrong code at -O3 in both 32-bit and 64-bit ↵Bin Cheng1-2/+16
modes on x86_64-linux-gnu) 2019-03-26 Bin Cheng <bin.cheng@linux.alibaba.com> PR tree-optimization/81740 * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): In case of outer loop vectorization, check for backward dependence at the inner loop if outer loop dependence is reversed. * gcc.dg/vect/pr81740-1.c: New testcase. * gcc.dg/vect/pr81740-2.c: Likewise. From-SVN: r269938
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-12-21tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Use ↵Jakub Jelinek1-3/+3
DR_TARGET_ALIGNMENT on dr_info rather than dr. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Use DR_TARGET_ALIGNMENT on dr_info rather than dr. Spelling fixes. From-SVN: r267318
2018-12-20tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Don't do ↵Joern Rennecke1-0/+14
versioning for data accesses with misaligned step. 2018-12-20 Joern Rennecke <joern.rennecke@riscy-ip.com> * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Don't do versioning for data accesses with misaligned step. From-SVN: r267314
2018-11-14fix Darwin bootstrap.Iain Sandoe1-1/+2
gcc/ * tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Cast MAX_OFILE_ALIGNMENT as needed. From-SVN: r266138
2018-11-13Ensure that dump calls are guarded with dump_enabled_pDavid Malcolm1-4/+6
If called when !dump_enabled_p, the dump_* functions effectively do nothing, but as of r263178 this doing "nothing" involves non-trivial work internally. I wasn't sure whether the dump_* functions should assert that dump_enabled_p () is true when they're called, or if they should bail out immediately for this case, so in this patch I implemented both, so that we get an assertion failure, and otherwise bail out for the case where !dump_enabled_p when assertions are disabled. The patch also fixes all of the places I found during testing (on x86_64-pc-linux-gnu) that call into dump_* but which weren't guarded by if (dump_enabled_p ()) gcc/ChangeLog: * dumpfile.c (VERIFY_DUMP_ENABLED_P): New macro. (dump_gimple_stmt): Use it. (dump_gimple_stmt_loc): Likewise. (dump_gimple_expr): Likewise. (dump_gimple_expr_loc): Likewise. (dump_generic_expr): Likewise. (dump_generic_expr_loc): Likewise. (dump_printf): Likewise. (dump_printf_loc): Likewise. (dump_dec): Likewise. (dump_dec): Likewise. (dump_hex): Likewise. (dump_symtab_node): Likewise. gcc/ChangeLog: * gimple-loop-interchange.cc (tree_loop_interchange::interchange): Guard dump call with dump_enabled_p. * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise. * graphite-optimize-isl.c (optimize_isl): Likewise. * graphite.c (graphite_transform_loops): Likewise. * tree-loop-distribution.c (pass_loop_distribution::execute): Likewise. * tree-parloops.c (parallelize_loops): Likewise. * tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise. * tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_update_vf_for_slp): Likewise. (vect_estimate_min_profitable_iters): Likewise. * tree-vect-slp.c (vect_record_max_nunits): Likewise. (vect_build_slp_tree_2): Likewise. (vect_supported_load_permutation_p): Likewise. (vect_slp_analyze_operations): Likewise. (vect_slp_analyze_bb_1): Likewise. (vect_slp_bb): Likewise. * tree-vect-stmts.c (vect_analyze_stmt): Likewise. * tree-vectorizer.c (try_vectorize_loop_1): Likewise. (pass_slp_vectorize::execute): Likewise. (increase_alignment): Likewise. From-SVN: r266080
2018-11-13[PATCH][GCC] Make DR_TARGET_ALIGNMENT compile time variableAndre Vieira1-29/+65
This patch enables targets to describe DR_TARGET_ALIGNMENT as a compile-time variable. It does so by turning the variable into a 'poly_uint64'. gcc/ChangeLog: 2018-11-13 Andre Vieira <andre.simoesdiasvieira@arm.com> * config/aarch64/aarch64.c (aarch64_vectorize_preferred_vector_alignment): Change return type to poly_uint64. (aarch64_simd_vector_alignment_reachable): Adapt to preferred vector alignment being a poly int. * doc/tm.texi (TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT): Change return type to poly_uint64. * target.def (default_preferred_vector_alignment): Likewise. * targhooks.c (default_preferred_vector_alignment): Likewise. * targhooks.h (default_preferred_vector_alignment): Likewise. * tree-vect-data-refs.c (vect_calculate_target_alignment): Likewise. (vect_compute_data_ref_alignment): Adapt to vector alignment being a poly int. (vect_update_misalignment_for_peel): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_find_same_alignment_drs): Likewise. (vect_duplicate_ssa_name_ptr_info): Likewise. (vect_setup_realignment): Likewise. (vect_can_force_dr_alignment_p): Change alignment parameter type to poly_uint64. * tree-vect-loop-manip.c (get_misalign_in_elems): Learn to construct a mask with a compile time variable vector alignment. (vect_gen_prolog_loop_niters): Adapt to vector alignment being a poly int. (vect_do_peeling): Exit early if vector alignment is not constant. * tree-vect-stmts.c (ensure_base_align): Adapt to vector alignment being a poly int. (vectorizable_store): Likewise. (vectorizable_load): Likweise. * tree-vectorizer.h (struct dr_vec_info): Make target_alignment field a poly_uint64. (vect_known_alignment_in_bytes): Adapt to vector alignment being a poly int. (vect_can_force_dr_alignment_p): Change alignment parameter type to poly_uint64. From-SVN: r266072
2018-10-26re PR tree-optimization/87746 (ICE in vect_update_misalignment_for_peel, at ↵Richard Biener1-20/+19
tree-vect-data-refs.c:1035) 2018-10-26 Richard Biener <rguenther@suse.de> PR tree-optimization/87746 * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Simplify and fix WRT strided store groups with size not equal to step in element count. (vect_analyze_group_access_1): Dump the whole group. * gcc.dg/pr87746.c: New testcase. From-SVN: r265517
2018-10-25tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Initialize ng to ↵Richard Biener1-1/+1
silence error with release checking bootstrap. 2018-10-25 Richard Biener <rguenther@suse.de> * tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Initialize ng to silence error with release checking bootstrap. From-SVN: r265491
2018-10-24re PR tree-optimization/87105 (Autovectorization [X86, SSE2, AVX2, ↵Richard Biener1-28/+80
DoublePrecision]) 2018-10-24 Richard Biener <rguenther@suse.de> PR tree-optimization/87105 * tree-vect-data-refs.c (vect_analyze_group_access_1): Adjust dump classification. (vect_analyze_data_ref_accesses): Handle duplicate loads and stores by splitting the affected group after the fact. * tree-vect-slp.c (vect_build_slp_tree_2): Dump when we fail the SLP build because of size constraints. * gcc.dg/vect/bb-slp-39.c: New testcase. * gfortran.dg/vect/pr83232.f90: Un-XFAIL. From-SVN: r265457
2018-10-24re PR tree-optimization/87665 (gcc HEAD (svn: 265340) breaks elements on resize)Richard Biener1-9/+19
2018-10-24 Richard Biener <rguenther@suse.de> PR tree-optimization/87665 * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Adjust to reflect reality. * gcc.dg/torture/pr87665.c: New testcase. From-SVN: r265452
2018-10-22Add a fun parameter to three stmt_could_throw... functionsMartin Jambor1-1/+1
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-04Report vectorization problems via a new opt_problem classDavid Malcolm1-192/+155
This is v3 of the patch; previous versions were: v2: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00446.html v1: https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01462.html This patch introduces a class opt_problem, along with wrapper classes for bool (opt_result) and for pointers (e.g. opt_loop_vec_info for loop_vec_info). opt_problem instances are created when an optimization problem is encountered, but only if dump_enabled_p. They are manually propagated up the callstack, and are manually reported at the "top level" of an optimization if dumping is enabled, to give the user a concise summary of the problem *after* the failure is reported. In particular, the location of the problematic statement is captured and emitted, rather than just the loop's location. For example: no-vfa-vect-102.c:24:3: missed: couldn't vectorize loop no-vfa-vect-102.c:27:7: missed: statement clobbers memory: __asm__ __volatile__("" : : : "memory"); Changed in v3: * This version bootstraps and passes regression testing (on x86_64-pc-linux-gnu). * added selftests, to exercise the opt_problem machinery * removed the "bool to opt_result" ctor, so that attempts to use e.g. return a bool from an opt_result-returning function will fail at compile time * use formatted printing within opt_problem ctor to replace the various dump_printf_loc calls * dropped i18n * changed the sense of vect_analyze_data_ref_dependence's return value (see the ChangeLog) * add MSG_PRIORITY_REEMITTED, so that -fopt-info can show the messages, without them messing up the counts in scan-tree-dump-times in DejaGnu tests gcc/ChangeLog: * Makefile.in (OBJS): Add opt-problem.o. * dump-context.h: Include "selftest.h. (selftest::temp_dump_context): New forward decl. (class dump_context): Make friend of class selftest::temp_dump_context. (dump_context::dump_loc_immediate): New decl. (class dump_pretty_printer): Move here from dumpfile.c. (class temp_dump_context): Move to namespace selftest. (temp_dump_context::temp_dump_context): Add param "forcibly_enable_dumping". (selftest::verify_dumped_text): (ASSERT_DUMPED_TEXT_EQ): Move here from dumpfile.c. (selftest::verify_item): (ASSERT_IS_TEXT): Move here from dumpfile.c. (ASSERT_IS_TREE): Likewise. (ASSERT_IS_GIMPLE): Likewise. * dumpfile.c (dump_context::dump_loc): Move immediate dumping to... (dump_context::dump_loc_immediate): ...this new function. (class dump_pretty_printer): Move to dump-context.h. (dump_switch_p_1): Don't enable MSG_PRIORITY_REEMITTED. (opt_info_switch_p_1): Enable MSG_PRIORITY_REEMITTED. (temp_dump_context::temp_dump_context): Move to "selftest" namespace. Add param "forcibly_enable_dumping", and use it to conditionalize the use of m_pp; (selftest::verify_dumped_text): Make non-static. (ASSERT_DUMPED_TEXT_EQ): Move to dump-context.h. (selftest::verify_item): Make non-static. (ASSERT_IS_TEXT): Move to dump-context.h. (ASSERT_IS_TREE): Likewise. (ASSERT_IS_GIMPLE): Likewise. (selftest::test_capture_of_dump_calls): Pass "true" for new param of temp_dump_context. * dumpfile.h (enum dump_flag): Add MSG_PRIORITY_REEMITTED, adding it to MSG_ALL_PRIORITIES. Update values of TDF_COMPARE_DEBUG and TDF_COMPARE_DEBUG. * opt-problem.cc: New file. * opt-problem.h: New file. * optinfo-emit-json.cc (selftest::test_building_json_from_dump_calls): Pass "true" for new param of temp_dump_context. * optinfo.cc (optinfo_kind_to_dump_flag): New function. (optinfo::emit_for_opt_problem): New function. (optinfo::emit): Clarity which emit_item is used. * optinfo.h (optinfo::get_dump_location): New accessor. (optinfo::emit_for_opt_problem): New decl. (optinfo::emit): Make const. * selftest-run-tests.c (selftest::run_tests): Call selftest::opt_problem_cc_tests. * selftest.h (selftest::opt_problem_cc_tests): New decl. * tree-data-ref.c (dr_analyze_innermost): Convert return type from bool to opt_result, converting fprintf messages to opt_result::failure_at calls. Add "stmt" param for use by the failure_at calls. (create_data_ref): Pass "stmt" to the dr_analyze_innermost call. (runtime_alias_check_p): Convert return type from bool to opt_result, converting dump_printf calls to opt_result::failure_at, using the statement DDR_A for their location. (find_data_references_in_stmt): Convert return type from bool to opt_result, converting "return false" to opt_result::failure_at with a new message. * tree-data-ref.h: Include "opt-problem.h". (dr_analyze_innermost): Convert return type from bool to opt_result, and add a const gimple * param. (find_data_references_in_stmt): Convert return type from bool to opt_result. (runtime_alias_check_p): Likewise. * tree-predcom.c (find_looparound_phi): Pass "init_stmt" to dr_analyze_innermost. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Convert return type from bool to opt_result, adding a message for the PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS zero case. (vect_analyze_data_ref_dependence): Convert return type from bool to opt_result. Change sense of return type from "false" effectively meaning "no problems" to "false" meaning a problem, so that "return false" becomes "return opt_result::success". Convert "return true" calls to opt_result::failure_at, using the location of statement A rather than vect_location. (vect_analyze_data_ref_dependences): Convert return type from bool to opt_result. (verify_data_ref_alignment): Likewise, converting dump_printf_loc calls to opt_result::failure_at, using the stmt location rather than vect_location. (vect_verify_datarefs_alignment): Convert return type from bool to opt_result. (vect_enhance_data_refs_alignment): Likewise. Split local "stat" into multiple more-tightly-scoped copies. (vect_analyze_data_refs_alignment): Convert return type from bool to opt_result. (vect_analyze_data_ref_accesses): Likewise, converting a "return false" to a "return opt_result::failure_at", adding a new message. (vect_prune_runtime_alias_test_list): Convert return type from bool to opt_result, converting dump_printf_loc to opt_result::failure_at. Add a %G to show the pertinent statement, and use the stmt's location rather than vect_location. (vect_find_stmt_data_reference): Convert return type from bool to opt_result, converting dump_printf_loc to opt_result::failure_at, using stmt's location. (vect_analyze_data_refs): Convert return type from bool to opt_result. Convert "return false" to "return opt_result::failure_at", adding messages as needed. * tree-vect-loop.c (vect_determine_vf_for_stmt_1): Convert return type from bool to opt_result. (vect_determine_vf_for_stmt): Likewise. (vect_determine_vectorization_factor): Likewise, converting dump_printf_loc to opt_result::failure_at, using location of phi rather than vect_location. (vect_analyze_loop_form_1): Convert return type from bool to opt_result, converting dump_printf_loc calls, retaining the use of vect_location. (vect_analyze_loop_form): Convert return type from loop_vec_info to opt_loop_vec_info. (vect_analyze_loop_operations): Convert return type from bool to opt_result, converting dump_printf_loc calls, using the location of phi/stmt rather than vect_location where available. Convert various "return false" to "return opt_result::failure_at" with "unsupported phi" messages. (vect_get_datarefs_in_loop): Convert return type from bool to opt_result. Add a message for the PARAM_LOOP_MAX_DATAREFS_FOR_DATADEPS failure. (vect_analyze_loop_2): Convert return type from bool to opt_result. Ensure "ok" is set to a opt_result::failure_at before each "goto again;", adding new messages where needed. Add "unsupported grouped {store|load}" messages. (vect_analyze_loop): Convert return type from loop_vec_info to opt_loop_vec_info. * tree-vect-slp.c (vect_analyze_slp): Convert return type from bool to opt_result. * tree-vect-stmts.c (process_use): Likewise, converting dump_printf_loc call and using stmt location, rather than vect_location. (vect_mark_stmts_to_be_vectorized): Likeise. (vect_analyze_stmt): Likewise, adding a %G. (vect_get_vector_types_for_stmt): Convert return type from bool to opt_result, converting dump_printf_loc calls and using stmt location, rather than vect_location. (vect_get_mask_type_for_stmt): Convert return type from tree to opt_tree, converting dump_printf_loc calls and using stmt location. * tree-vectorizer.c: Include "opt-problem.h. (try_vectorize_loop_1): Flag "Analyzing loop at" dump message as MSG_PRIORITY_INTERNALS. Convert local "loop_vinfo" from loop_vec_info to opt_loop_vec_info. If if fails, and dumping is enabled, use it to report at the top level "couldn't vectorize loop" followed by the problem. * tree-vectorizer.h (opt_loop_vec_info): New typedef. (vect_mark_stmts_to_be_vectorized): Convert return type from bool to opt_result. (vect_analyze_stmt): Likewise. (vect_get_vector_types_for_stmt): Likewise. (tree vect_get_mask_type_for_stmt): Likewise. (vect_analyze_data_ref_dependences): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_analyze_data_refs_alignment): Likewise. (vect_verify_datarefs_alignment): Likewise. (vect_analyze_data_ref_accesses): Likewise. (vect_prune_runtime_alias_test_list): Likewise. (vect_find_stmt_data_reference): Likewise. (vect_analyze_data_refs): Likewise. (vect_analyze_loop): Convert return type from loop_vec_info to opt_loop_vec_info. (vect_analyze_loop_form): Likewise. (vect_analyze_slp): Convert return type from bool to opt_result. gcc/testsuite/ChangeLog: * gcc.dg/vect/nodump-vect-opt-info-2.c: New test. * gcc.dg/vect/vect-alias-check-4.c: Add "-fopt-info-vec-all" to dg-additional-options. Add dg-message and dg-missed directives to verify that -fopt-info messages are written at the correct locations. From-SVN: r264852
2018-09-19dump_printf: use %T and %G throughoutDavid Malcolm1-326/+155
As promised at Cauldron, this patch uses %T and %G with dump_printf and dump_printf_loc calls to eliminate calls to dump_generic_expr (MSG_*, arg, TDF_SLIM) (via %T) and dump_gimple_stmt (MSG_*, TDF_SLIM, stmt, 0) (via %G) throughout the middle-end, simplifying numerous dump callsites. A few calls to these functions didn't match the above pattern; I didn't touch these. I wasn't able to use %E anywhere. gcc/ChangeLog: * tree-data-ref.c (runtime_alias_check_p): Use formatted printing with %T in place of calls to dump_generic_expr. (prune_runtime_alias_test_list): Likewise. (create_runtime_alias_checks): Likewise. * tree-vect-data-refs.c (vect_check_nonzero_value): Likewise. (vect_analyze_data_ref_dependence): Likewise. (vect_slp_analyze_data_ref_dependence): Likewise. (vect_record_base_alignment): Likewise. Use %G in place of call to dump_gimple_stmt. (vect_compute_data_ref_alignment): Likewise. (verify_data_ref_alignment): Likewise. (vect_find_same_alignment_drs): Likewise. (vect_analyze_group_access_1): Likewise. (vect_analyze_data_ref_accesses): Likewise. (dependence_distance_ge_vf): Likewise. (dump_lower_bound): Likewise. (vect_prune_runtime_alias_test_list): Likewise. (vect_find_stmt_data_reference): Likewise. (vect_analyze_data_refs): Likewise. (vect_create_addr_base_for_vector_ref): Likewise. (vect_create_data_ref_ptr): Likewise. * tree-vect-loop-manip.c (vect_set_loop_condition): Likewise. (vect_can_advance_ivs_p): Likewise. (vect_update_ivs_after_vectorizer): Likewise. (vect_gen_prolog_loop_niters): Likewise. (vect_prepare_for_masked_peels): Likewise. * tree-vect-loop.c (vect_determine_vf_for_stmt): Likewise. (vect_determine_vectorization_factor): Likewise. (vect_is_simple_iv_evolution): Likewise. (vect_analyze_scalar_cycles_1): Likewise. (vect_analyze_loop_operations): Likewise. (report_vect_op): Likewise. (vect_is_slp_reduction): Likewise. (check_reduction_path): Likewise. (vect_is_simple_reduction): Likewise. (vect_create_epilog_for_reduction): Likewise. (vect_finalize_reduction:): Likewise. (vectorizable_induction): Likewise. (vect_transform_loop_stmt): Likewise. (vect_transform_loop): Likewise. (optimize_mask_stores): Likewise. * tree-vect-patterns.c (vect_pattern_detected): Likewise. (vect_split_statement): Likewise. (vect_recog_over_widening_pattern): Likewise. (vect_recog_average_pattern): Likewise. (vect_determine_min_output_precision_1): Likewise. (vect_determine_precisions_from_range): Likewise. (vect_determine_precisions_from_users): Likewise. (vect_mark_pattern_stmts): Likewise. (vect_pattern_recog_1): Likewise. * tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise. (vect_record_max_nunits): Likewise. (vect_build_slp_tree_1): Likewise. (vect_build_slp_tree_2): Likewise. (vect_print_slp_tree): Likewise. (vect_analyze_slp_instance): Likewise. (vect_detect_hybrid_slp_stmts): Likewise. (vect_detect_hybrid_slp_1): Likewise. (vect_slp_analyze_operations): Likewise. (vect_slp_analyze_bb_1): Likewise. (vect_transform_slp_perm_load): Likewise. (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vect_mark_relevant): Likewise. (vect_mark_stmts_to_be_vectorized): Likewise. (vect_init_vector_1): Likewise. (vect_get_vec_def_for_operand): Likewise. (vect_finish_stmt_generation_1): Likewise. (vect_check_load_store_mask): Likewise. (vectorizable_call): Likewise. (vectorizable_conversion): Likewise. (vectorizable_operation): Likewise. (vectorizable_load): Likewise. (vect_analyze_stmt): Likewise. (vect_is_simple_use): Likewise. (vect_get_vector_types_for_stmt): Likewise. (vect_get_mask_type_for_stmt): Likewise. * tree-vectorizer.c (increase_alignment): Likewise. From-SVN: r264424
2018-08-23tree-vect-data-refs.c (vect_grouped_store_supported): Fix typo "permutaion".Prathamesh Kulkarni1-1/+1
2018-08-23 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> * tree-vect-data-refs.c (vect_grouped_store_supported): Fix typo "permutaion". From-SVN: r263819
2018-08-22Make the vectoriser drop to strided accesses for stores with gapsRichard Sandiford1-4/+4
We could vectorise: for (...) { a[0] = ...; a[1] = ...; a[2] = ...; a[3] = ...; a += stride; } (including the case when stride == 8) but not: for (...) { a[0] = ...; a[1] = ...; a[2] = ...; a[3] = ...; a += 8; } (where the stride is always 8). The former was treated as a "grouped and strided" store, while the latter was treated as a grouped store with gaps, which we don't support. This patch makes us treat groups of stores with gaps at the end as strided groups too. I tried to go through all uses of STMT_VINFO_STRIDED_P and all vector uses of DR_STEP to see whether there were any hard-baked assumptions, but couldn't see any. I wondered whether we should relax: /* We do not have to consider dependences between accesses that belong to the same group, unless the stride could be smaller than the group size. */ if (DR_GROUP_FIRST_ELEMENT (stmtinfo_a) && (DR_GROUP_FIRST_ELEMENT (stmtinfo_a) == DR_GROUP_FIRST_ELEMENT (stmtinfo_b)) && !STMT_VINFO_STRIDED_P (stmtinfo_a)) return false; for cases in which the step is constant and the absolute step is known to be greater than the group size, but data dependence analysis should already return chrec_known for those cases. The new test is a version of vect-avg-15.c with the variable step replaced by a constant one. A natural follow-on would be to do the same for groups with gaps in the middle: /* Check that the distance between two accesses is equal to the type size. Otherwise, we have gaps. */ diff = (TREE_INT_CST_LOW (DR_INIT (data_ref)) - TREE_INT_CST_LOW (prev_init)) / type_size; if (diff != 1) { [...] if (DR_IS_WRITE (data_ref)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "interleaved store with gaps\n"); return false; } But I think we should do that separately and see what the fallout from this change is first. 2018-08-22 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_analyze_group_access_1): Convert grouped stores with gaps to a strided group. gcc/testsuite/ * gcc.dg/vect/vect-avg-16.c: New test. * gcc.dg/vect/slp-37.c: Expect the loop to be vectorized. * gcc.dg/vect/vect-strided-u8-i8-gap4.c, * gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c: Likewise for the second loop in main1. From-SVN: r263772
2018-08-17Formatted printing for dump_* in the middle-endDavid Malcolm1-5/+3
This patch converts dump_print and dump_printf_loc from using printf (and thus ATTRIBUTE_PRINTF) to using a new pretty-printer based on pp_format, which supports formatting middle-end types. In particular, the following codes are implemented (in addition to the standard pretty_printer ones): %E: gimple *: Equivalent to: dump_gimple_expr (MSG_*, TDF_SLIM, stmt, 0) %G: gimple *: Equivalent to: dump_gimple_stmt (MSG_*, TDF_SLIM, stmt, 0) %T: tree: Equivalent to: dump_generic_expr (MSG_*, arg, TDF_SLIM). Hence it becomes possible to convert e.g.: if (dump_enabled_p ()) { dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "not vectorized: different sized vector " "types in statement, "); dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype); dump_printf (MSG_MISSED_OPTIMIZATION, " and "); dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, nunits_vectype); dump_printf (MSG_MISSED_OPTIMIZATION, "\n"); } into a one-liner: if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "not vectorized: different sized vector " "types in statement, %T and %T\n", vectype, nunits_vectype); Unlike regular pretty-printers, this one captures optinfo_item instances for the formatted chunks as appropriate, so that when written out to a JSON optimization record, the relevant parts of the message are labelled by type, and by source location (so that e.g. %G is entirely equivalent to using dump_gimple_stmt). dump_printf and dump_printf_loc become marked with ATTRIBUTE_GCC_DUMP_PRINTF, which the patch also implements. gcc/c-family/ChangeLog: * c-format.c (enum format_type): Add gcc_dump_printf_format_type. (gcc_dump_printf_length_specs): New. (gcc_dump_printf_flag_pairs): New. (gcc_dump_printf_flag_specs): New. (gcc_dump_printf_char_table): New. (format_types_orig): Add entry for "gcc_dump_printf". (init_dynamic_diag_info): Set up length_char_specs and conversion_specs for gcc_dump_printf_format_type. (handle_format_attribute): Handle gcc_dump_printf_format_type. gcc/ChangeLog: * dump-context.h: Include "dumpfile.h". (dump_context::dump_printf_va): Convert final param from va_list to va_list *. Convert from ATTRIBUTE_PRINTF to ATTRIBUTE_GCC_DUMP_PRINTF. (dump_context::dump_printf_loc_va): Likewise. * dumpfile.c: Include "stringpool.h". (make_item_for_dump_printf_va): Delete. (make_item_for_dump_printf): Delete. (class dump_pretty_printer): New class. (dump_pretty_printer::dump_pretty_printer): New ctor. (dump_pretty_printer::emit_items): New member function. (dump_pretty_printer::emit_any_pending_textual_chunks): New member function. (dump_pretty_printer::emit_item): New member function. (dump_pretty_printer::stash_item): New member function. (dump_pretty_printer::format_decoder_cb): New member function. (dump_pretty_printer::decode_format): New member function. (dump_context::dump_printf_va): Reimplement in terms of dump_pretty_printer. (dump_context::dump_printf_loc_va): Convert final param from va_list to va_list *. (dump_context::begin_scope): Reimplement call to make_item_for_dump_printf. (dump_printf): Update for change to dump_printf_va. (dump_printf_loc): Likewise. (selftest::test_capture_of_dump_calls): Convert "stmt" from greturn * to gimple *. Add a test_decl. Add tests of dump_printf with %T, %E, and %G. * dumpfile.h (ATTRIBUTE_GCC_DUMP_PRINTF): New macro. (dump_printf): Replace ATTRIBUTE_PRINTF_2 with ATTRIBUTE_GCC_DUMP_PRINTF (2, 3). (dump_printf_loc): Replace ATTRIBUTE_PRINTF_3 with ATTRIBUTE_GCC_DUMP_PRINTF (3, 0). * tree-vect-data-refs.c (vect_lanes_optab_supported_p): Convert use of HOST_WIDE_INT_PRINT_DEC on unsigned HOST_WIDE_INT "count" within a dump_printf_loc call to "%wu". (vector_alignment_reachable_p): Merge two dump_printf[_loc] calls, converting a use of HOST_WIDE_INT_PRINT_DEC to "%wd". Add a missing space after "=". * tree-vect-loop.c (vect_analyze_loop_2) Within a dump_printf call, convert use of HOST_WIDE_INT_PRINT_DEC to "%wd". * tree-vect-slp.c (vect_slp_bb): Within a dump_printf_loc call, convert use of HOST_WIDE_INT_PRINT_UNSIGNED to "%wu". * tree-vectorizer.c (try_vectorize_loop_1): Likewise. Remove duplicate "vectorized" from message. gcc/testsuite/ChangeLog: * gcc.dg/format/gcc_diag-1.c: Fix typo. Add test coverage for gcc_dump_printf. * gcc.dg/format/gcc_diag-10.c: Add gimple typedef. Add test coverage for gcc_dump_printf. From-SVN: r263626
2018-08-01[06/11] Handle VMAT_INVARIANT separatelyRichard Sandiford1-22/+11
Invariant loads were handled as a variation on the code for contiguous loads. We detected whether they were invariant or not as a byproduct of creating the vector pointer ivs: vect_create_data_ref_ptr passed back an inv_p to say whether the pointer was invariant. But vectorised invariant loads just keep the original scalar load, so this meant that detecting invariant loads had the side-effect of creating an unwanted vector pointer iv. The placement of the code also meant that we'd create a vector load and then not use the result. In principle this is wrong code, since there's no guarantee that there's a vector's worth of accessible data at that address, but we rely on DCE to get rid of the load before any harm is done. E.g., for an invariant load in an inner loop (which seems like the more common use case for this code), we'd create: vectp_a.6_52 = &a + 4; # vectp_a.5_53 = PHI <vectp_a.5_54(9), vectp_a.6_52(2)> # vectp_a.5_55 = PHI <vectp_a.5_53(3), vectp_a.5_56(10)> vect_next_a_11.7_57 = MEM[(int *)vectp_a.5_55]; next_a_11 = a[_1]; vect_cst__58 = {next_a_11, next_a_11, next_a_11, next_a_11}; vectp_a.5_56 = vectp_a.5_55 + 4; vectp_a.5_54 = vectp_a.5_53 + 0; whereas all we want is: next_a_11 = a[_1]; vect_cst__58 = {next_a_11, next_a_11, next_a_11, next_a_11}; This patch moves the handling to its own block and makes vect_create_data_ref_ptr assert (when creating a full iv) that the address isn't invariant. The ncopies handling is unfortunate, but a preexisting issue. Richi's suggestion of using a vector of vector statements would let us reuse one statement for all copies. 2018-08-01 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vect_create_data_ref_ptr): Remove inv_p parameter. * tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise. When creating an iv, assert that the step is not known to be zero. (vect_setup_realignment): Update call accordingly. * tree-vect-stmts.c (vectorizable_store): Likewise. (vectorizable_load): Likewise. Handle VMAT_INVARIANT separately. From-SVN: r263220
2018-08-01[04/11] Add a vect_orig_stmt helper functionRichard Sandiford1-4/+2
This patch just adds a helper function for going from a potential pattern statement to the original scalar statement. 2018-08-01 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vect_orig_stmt): New function. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Use it. * tree-vect-loop.c (vect_model_reduction_cost): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorizable_live_operation): Likewise. * tree-vect-slp.c (vect_find_last_scalar_stmt_in_slp): Likewise. (vect_detect_hybrid_slp_stmts, vect_schedule_slp): Likewise. * tree-vect-stmts.c (vectorizable_call): Likewise. (vectorizable_simd_clone_call, vect_remove_stores): Likewise. From-SVN: r263217
2018-07-31[40/46] Add vec_info::lookup_drRichard Sandiford1-43/+45
This patch replaces DR_VECT_AUX and vect_dr_stmt with a new vec_info::lookup_dr function, so that the lookup is relative to a particular vec_info rather than to global state. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vec_info::lookup_dr): New member function. (vect_dr_stmt): Delete. * tree-vectorizer.c (vec_info::lookup_dr): New function. * tree-vect-loop-manip.c (vect_update_inits_of_drs): Use it instead of DR_VECT_AUX. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr) (vect_analyze_data_ref_dependence, vect_record_base_alignments) (vect_verify_datarefs_alignment, vect_peeling_supportable) (vect_analyze_data_ref_accesses, vect_prune_runtime_alias_test_list) (vect_analyze_data_refs): Likewise. (vect_slp_analyze_data_ref_dependence): Likewise. Take a vec_info argument. (vect_find_same_alignment_drs): Likewise. (vect_slp_analyze_node_dependences): Update calls accordingly. (vect_analyze_data_refs_alignment): Likewise. Use vec_info::lookup_dr instead of DR_VECT_AUX. (vect_get_peeling_costs_all_drs): Take a loop_vec_info instead of a vector data references. Use vec_info::lookup_dr instead of DR_VECT_AUX. (vect_peeling_hash_get_lowest_cost): Update calls accordingly. (vect_enhance_data_refs_alignment): Likewise. Use vec_info::lookup_dr instead of DR_VECT_AUX. From-SVN: r263155
2018-07-31[39/46] Change STMT_VINFO_UNALIGNED_DR to a dr_vec_infoRichard Sandiford1-1/+1
After previous changes, it makes more sense for STMT_VINFO_UNALIGNED_DR to be dr_vec_info rather than a data_reference. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_loop_vec_info::unaligned_dr): Change to dr_vec_info. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Update accordingly. * tree-vect-loop.c (vect_analyze_loop_2): Likewise. * tree-vect-loop-manip.c (get_misalign_in_elems): Likewise. (vect_gen_prolog_loop_niters): Likewise. From-SVN: r263154
2018-07-31[38/46] Use dr_vec_info to represent a data referenceRichard Sandiford1-295/+338
This patch makes various routines (mostly in tree-vect-data-refs.c) take dr_vec_infos rather than data_references. The affected routines are really dealing with the way that an access is going to vectorised, rather than with the original scalar access described by the data_reference. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (set_dr_misalignment, dr_misalignment) (DR_TARGET_ALIGNMENT, aligned_access_p, known_alignment_for_access_p) (vect_known_alignment_in_bytes, vect_dr_behavior) (vect_get_scalar_dr_size): Take references as dr_vec_infos instead of data_references. Update calls to other routines for which the same change has been made. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Take dr_vec_infos instead of stmt_vec_infos. (vect_analyze_data_ref_dependence): Update call accordingly. (vect_slp_analyze_data_ref_dependence) (vect_record_base_alignments): Use DR_VECT_AUX. (vect_calculate_target_alignment, vect_compute_data_ref_alignment) (vect_update_misalignment_for_peel, verify_data_ref_alignment) (vector_alignment_reachable_p, vect_get_data_access_cost) (vect_peeling_supportable, vect_analyze_group_access_1) (vect_analyze_group_access, vect_analyze_data_ref_access) (vect_vfa_segment_size, vect_vfa_access_size, vect_vfa_align) (vect_compile_time_alias, vect_small_gap_p) (vectorizable_with_step_bound_p, vect_duplicate_ssa_name_ptr_info): (vect_supportable_dr_alignment): Take references as dr_vec_infos instead of data_references. Update calls to other routines for which the same change has been made. (vect_verify_datarefs_alignment, vect_get_peeling_costs_all_drs) (vect_find_same_alignment_drs, vect_analyze_data_refs_alignment) (vect_slp_analyze_and_verify_node_alignment) (vect_analyze_data_ref_accesses, vect_prune_runtime_alias_test_list) (vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr) (vect_setup_realignment): Use dr_vec_infos. Update calls after above changes. (_vect_peel_info::dr): Replace with... (_vect_peel_info::dr_info): ...this new field. (vect_peeling_hash_get_most_frequent) (vect_peeling_hash_choose_best_peeling): Update accordingly. (vect_peeling_hash_get_lowest_cost): (vect_enhance_data_refs_alignment): Likewise. Update calls to other routines for which the same change has been made. (vect_peeling_hash_insert): Likewise. Take a dr_vec_info instead of a data_reference. * tree-vect-loop-manip.c (get_misalign_in_elems) (vect_gen_prolog_loop_niters): Use dr_vec_infos. Update calls after above changes. * tree-vect-loop.c (vect_analyze_loop_2): Likewise. * tree-vect-stmts.c (vect_get_store_cost, vect_get_load_cost) (vect_truncate_gather_scatter_offset, compare_step_with_zero) (get_group_load_store_type, get_negative_load_store_type) (vect_get_data_ptr_increment, vectorizable_store) (vectorizable_load): Likewise. (ensure_base_align): Take a dr_vec_info instead of a data_reference. Update calls to other routines for which the same change has been made. From-SVN: r263153
2018-07-31[37/46] dr_aux tweaksRichard Sandiford1-4/+4
This patch makes dr_aux link back to both the scalar data_reference and the containing stmt_vec_info, so that it becomes a suitable key for a vectorisable reference. The data_reference link is just STMT_VINFO_DATA_REF, moved here from _stmt_vec_info. The stmt pointer is a new field and always tracks the current stmt_vec_info for the reference (which might be a pattern stmt or the original stmt). The patch also makes the dr_aux in this current stmt be the one that counts, rather than have the information stay with the DR_STMT. A new macro (STMT_VINFO_DR_INFO) gives this information for a given stmt_info. In future we could make dr_aux a separate structure, which would be useful if we want to support multiple data references per stmt. That seems too much of a diversion for this series though. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vec_info::move_dr): New member function. (dataref_aux): Rename to... (dr_vec_info): ...this and add "dr" and "stmt" fields. (_stmt_vec_info::dr_aux): Update accordingly. (_stmt_vec_info::data_ref_info): Delete. (STMT_VINFO_GROUPED_ACCESS, DR_GROUP_FIRST_ELEMENT) (DR_GROUP_NEXT_ELEMENT, DR_GROUP_SIZE, DR_GROUP_STORE_COUNT) (DR_GROUP_GAP, DR_GROUP_SAME_DR_STMT, REDUC_GROUP_FIRST_ELEMENT): (REDUC_GROUP_NEXT_ELEMENT, REDUC_GROUP_SIZE): Use dr_aux.dr instead of data_ref. (STMT_VINFO_DATA_REF): Likewise. Turn into an lvalue. (STMT_VINFO_DR_INFO): New macro. (DR_VECT_AUX): Use STMT_VINFO_DR_INKFO and vect_dr_stmt. (set_dr_misalignment): Update after rename of dataref_aux. (vect_dr_stmt): Move earlier in file. Return dr_aux.stmt. * tree-vect-stmts.c (new_stmt_vec_info): Remove redundant initialization of STMT_VINFO_DATA_REF. * tree-vectorizer.c (vec_info::move_dr): New function. * tree-vect-patterns.c (vect_recog_bool_pattern) (vect_recog_mask_conversion_pattern) (vect_recog_gather_scatter_pattern): Use it. * tree-vect-data-refs.c (vect_analyze_data_refs): Initialize the "dr" and "stmt" fields of dr_vec_info instead of STMT_VINFO_DATA_REF. From-SVN: r263152
2018-07-31[33/46] Use stmt_vec_infos instead of vec_info/gimple stmt pairsRichard Sandiford1-7/+7
This patch makes vect_record_max_nunits and vect_record_base_alignment take a stmt_vec_info instead of a vec_info/gimple pair. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_record_base_alignment): Replace vec_info and gimple stmt arguments with a stmt_vec_info. (vect_record_base_alignments): Update calls accordingly. * tree-vect-slp.c (vect_record_max_nunits): Replace vec_info and gimple stmt arguments with a stmt_vec_info. (vect_build_slp_tree_1): Remove vinfo argument and update call to vect_record_max_nunits. (vect_build_slp_tree_2): Update calls to vect_build_slp_tree_1 and vect_record_max_nunits. From-SVN: r263148
2018-07-31[32/46] Use stmt_vec_info in function interfaces (part 2)Richard Sandiford1-62/+52
This second part handles the mechanical change from a gimple stmt argument to a stmt_vec_info argument. It updates the function comments if they referred to the argument by name, but it doesn't try to retrofit mentions to other functions. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (nested_in_vect_loop_p): Move further down file and take a stmt_vec_info instead of a gimple stmt. (supportable_widening_operation, vect_finish_replace_stmt) (vect_finish_stmt_generation, vect_get_store_rhs) (vect_get_vec_def_for_operand_1, vect_get_vec_def_for_operand) (vect_get_vec_defs, vect_init_vector, vect_transform_stmt) (vect_remove_stores, vect_analyze_stmt, vectorizable_condition) (vect_get_smallest_scalar_type, vect_check_gather_scatter) (vect_create_data_ref_ptr, bump_vector_ptr) (vect_permute_store_chain, vect_setup_realignment) (vect_transform_grouped_load, vect_record_grouped_load_vectors) (vect_create_addr_base_for_vector_ref, vectorizable_live_operation) (vectorizable_reduction, vectorizable_induction) (get_initial_def_for_reduction, is_simple_and_all_uses_invariant) (vect_get_place_in_interleaving_chain): Take stmt_vec_infos rather than gimple stmts as arguments. * tree-vect-data-refs.c (vect_get_smallest_scalar_type) (vect_preserves_scalar_order_p, vect_slp_analyze_node_dependences) (can_group_stmts_p, vect_check_gather_scatter) (vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr) (bump_vector_ptr, vect_permute_store_chain, vect_setup_realignment) (vect_permute_load_chain, vect_shift_permute_load_chain) (vect_transform_grouped_load) (vect_record_grouped_load_vectors): Likewise. * tree-vect-loop.c (vect_fixup_reduc_chain) (get_initial_def_for_reduction, vect_create_epilog_for_reduction) (vectorize_fold_left_reduction, is_nonwrapping_integer_induction) (vectorizable_reduction, vectorizable_induction) (vectorizable_live_operation, vect_loop_kill_debug_uses): Likewise. * tree-vect-patterns.c (type_conversion_p, adjust_bool_stmts) (vect_get_load_store_mask): Likewise. * tree-vect-slp.c (vect_get_place_in_interleaving_chain) (vect_analyze_slp_instance, vect_mask_constant_operand_p): Likewise. * tree-vect-stmts.c (vect_mark_relevant) (is_simple_and_all_uses_invariant) (exist_non_indexing_operands_for_use_p, process_use) (vect_init_vector_1, vect_init_vector, vect_get_vec_def_for_operand_1) (vect_get_vec_def_for_operand, vect_get_vec_defs) (vect_finish_stmt_generation_1, vect_finish_replace_stmt) (vect_finish_stmt_generation, vect_truncate_gather_scatter_offset) (compare_step_with_zero, vect_get_store_rhs, get_group_load_store_type) (get_negative_load_store_type, get_load_store_type) (vect_check_load_store_mask, vect_check_store_rhs) (vect_build_gather_load_calls, vect_get_strided_load_store_ops) (vectorizable_bswap, vectorizable_call, vectorizable_simd_clone_call) (vect_create_vectorized_demotion_stmts, vectorizable_conversion) (vectorizable_assignment, vectorizable_shift, vectorizable_operation) (get_group_alias_ptr_type, vectorizable_store, hoist_defs_of_uses) (vectorizable_load, vectorizable_condition, vectorizable_comparison) (vect_analyze_stmt, vect_transform_stmt, vect_remove_stores) (supportable_widening_operation): Likewise. From-SVN: r263147
2018-07-31[31/46] Use stmt_vec_info in function interfaces (part 1)Richard Sandiford1-4/+5
This first (less mechanical) part handles cases that involve changes in the callers or non-trivial changes in the functions themselves. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_describe_gather_scatter_call): Take a stmt_vec_info instead of a gcall. (vect_check_gather_scatter): Update call accordingly. * tree-vect-loop-manip.c (iv_phi_p): Take a stmt_vec_info instead of a gphi. (vect_can_advance_ivs_p, vect_update_ivs_after_vectorizer) (slpeel_update_phi_nodes_for_loops):): Update calls accordingly. * tree-vect-loop.c (vect_transform_loop_stmt): Take a stmt_vec_info instead of a gimple stmt. (vect_transform_loop): Update calls accordingly. * tree-vect-slp.c (vect_split_slp_store_group): Take and return stmt_vec_infos instead of gimple stmts. (vect_analyze_slp_instance): Update use accordingly. * tree-vect-stmts.c (read_vector_array, write_vector_array) (vect_clobber_variable, vect_stmt_relevant_p, permute_vec_elements) (vect_use_strided_gather_scatters_p, vect_build_all_ones_mask) (vect_build_zero_merge_argument, vect_get_gather_scatter_ops) (vect_gen_widened_results_half, vect_get_loop_based_defs) (vect_create_vectorized_promotion_stmts, can_vectorize_live_stmts): Take a stmt_vec_info instead of a gimple stmt and pass stmt_vec_infos down to subroutines. From-SVN: r263146
2018-07-31[28/46] Use stmt_vec_info instead of gimple stmts internally (part 1)Richard Sandiford1-33/+33
This first part makes functions use stmt_vec_infos instead of gimple stmts in cases where the stmt_vec_info was already available and where the change is mechanical. Most of it is just replacing "stmt" with "stmt_info". 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_slp_analyze_node_dependences): (vect_check_gather_scatter, vect_create_data_ref_ptr, bump_vector_ptr) (vect_permute_store_chain, vect_setup_realignment) (vect_permute_load_chain, vect_shift_permute_load_chain) (vect_transform_grouped_load): Use stmt_vec_info rather than gimple stmts internally, and when passing values to other vectorizer routines. * tree-vect-loop-manip.c (vect_can_advance_ivs_p): Likewise. * tree-vect-loop.c (vect_analyze_scalar_cycles_1) (vect_analyze_loop_operations, get_initial_def_for_reduction) (vect_create_epilog_for_reduction, vectorize_fold_left_reduction) (vectorizable_reduction, vectorizable_induction) (vectorizable_live_operation, vect_transform_loop_stmt) (vect_transform_loop): Likewise. * tree-vect-patterns.c (vect_reassociating_reduction_p) (vect_recog_widen_op_pattern, vect_recog_mixed_size_cond_pattern) (vect_recog_bool_pattern, vect_recog_gather_scatter_pattern): Likewise. * tree-vect-slp.c (vect_analyze_slp_instance): Likewise. (vect_slp_analyze_node_operations_1): Likewise. * tree-vect-stmts.c (vect_mark_relevant, process_use) (exist_non_indexing_operands_for_use_p, vect_init_vector_1) (vect_mark_stmts_to_be_vectorized, vect_get_vec_def_for_operand) (vect_finish_stmt_generation_1, get_group_load_store_type) (get_load_store_type, vect_build_gather_load_calls) (vectorizable_bswap, vectorizable_call, vectorizable_simd_clone_call) (vect_create_vectorized_demotion_stmts, vectorizable_conversion) (vectorizable_assignment, vectorizable_shift, vectorizable_operation) (vectorizable_store, vectorizable_load, vectorizable_condition) (vectorizable_comparison, vect_analyze_stmt, vect_transform_stmt) (supportable_widening_operation): Likewise. (vect_get_vector_types_for_stmt): Likewise. * tree-vectorizer.h (vect_dr_behavior): Likewise. From-SVN: r263143
2018-07-31[27/46] Remove duplicated stmt_vec_info lookupsRichard Sandiford1-12/+16
Various places called vect_dr_stmt or vinfo_for_stmt multiple times on the same input. This patch makes them reuse the earlier result. It also splits a couple of single vinfo_for_stmt calls out into separate statements so that they can be reused in later patches. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_analyze_data_ref_dependence) (vect_slp_analyze_node_dependences, vect_analyze_data_ref_accesses) (vect_permute_store_chain, vect_permute_load_chain) (vect_shift_permute_load_chain, vect_transform_grouped_load): Avoid repeated stmt_vec_info lookups. * tree-vect-loop-manip.c (vect_can_advance_ivs_p): Likewise. (vect_update_ivs_after_vectorizer): Likewise. * tree-vect-loop.c (vect_is_simple_reduction): Likewise. (vect_create_epilog_for_reduction, vectorizable_reduction): Likewise. * tree-vect-patterns.c (adjust_bool_stmts): Likewise. * tree-vect-slp.c (vect_analyze_slp_instance): Likewise. (vect_bb_slp_scalar_cost): Likewise. * tree-vect-stmts.c (get_group_alias_ptr_type): Likewise. From-SVN: r263142
2018-07-31[26/46] Make more use of dyn_cast in tree-vect*Richard Sandiford1-15/+18
If we use stmt_vec_infos to represent statements in the vectoriser, it's then more natural to use dyn_cast when processing the statement as an assignment, call, etc. This patch does that in a few more places. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-data-refs.c (vect_check_gather_scatter): Pass the gcall rather than the generic gimple stmt to gimple_call_internal_fn. (vect_get_smallest_scalar_type, can_group_stmts_p): Use dyn_cast to get gassigns and gcalls, rather than operating on generc gimple stmts. * tree-vect-stmts.c (exist_non_indexing_operands_for_use_p) (vect_mark_stmts_to_be_vectorized, vectorizable_store) (vectorizable_load, vect_analyze_stmt): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise gphi. From-SVN: r263141
2018-07-31[25/46] Make get_earlier/later_stmt take and return stmt_vec_infosRichard Sandiford1-8/+8
...and also make vect_find_last_scalar_stmt_in_slp return a stmt_vec_info. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (get_earlier_stmt, get_later_stmt): Take and return stmt_vec_infos rather than gimple stmts. Do not accept null arguments. (vect_find_last_scalar_stmt_in_slp): Return a stmt_vec_info instead of a gimple stmt. * tree-vect-slp.c (vect_find_last_scalar_stmt_in_slp): Likewise. Update use of get_later_stmt. (vect_get_constant_vectors): Update call accordingly. (vect_schedule_slp_instance): Likewise * tree-vect-data-refs.c (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_preserves_scalar_order_p): Update use of get_earlier_stmt. From-SVN: r263140
2018-07-31[23/46] Make LOOP_VINFO_MAY_MISALIGN_STMTS use stmt_vec_infoRichard Sandiford1-4/+3
This patch changes LOOP_VINFO_MAY_MISALIGN_STMTS from an auto_vec<gimple *> to an auto_vec<stmt_vec_info>. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_loop_vec_info::may_misalign_stmts): Change from an auto_vec<gimple *> to an auto_vec<stmt_vec_info>. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Update accordingly. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Likewise. From-SVN: r263138
2018-07-31[20/46] Make *FIRST_ELEMENT and *NEXT_ELEMENT stmt_vec_infosRichard Sandiford1-60/+52
This patch changes {REDUC,DR}_GROUP_{FIRST,NEXT} element from a gimple stmt to stmt_vec_info. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_stmt_vec_info::first_element): Change from a gimple stmt to a stmt_vec_info. (_stmt_vec_info::next_element): Likewise. * tree-vect-data-refs.c (vect_update_misalignment_for_peel) (vect_slp_analyze_and_verify_node_alignment) (vect_analyze_group_access_1, vect_analyze_group_access) (vect_small_gap_p, vect_prune_runtime_alias_test_list) (vect_create_data_ref_ptr, vect_record_grouped_load_vectors) (vect_supportable_dr_alignment): Update accordingly. * tree-vect-loop.c (vect_fixup_reduc_chain): Likewise. (vect_fixup_scalar_cycles_with_patterns, vect_is_slp_reduction) (vect_is_simple_reduction, vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_reassociating_reduction_p): Likewise. * tree-vect-slp.c (vect_build_slp_tree_1) (vect_attempt_slp_rearrange_stmts, vect_supported_load_permutation_p) (vect_split_slp_store_group, vect_analyze_slp_instance) (vect_analyze_slp, vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (vect_model_store_cost, vect_model_load_cost) (get_group_load_store_type, get_load_store_type) (get_group_alias_ptr_type, vectorizable_store, vectorizable_load) (vect_transform_stmt, vect_remove_stores): Likewise. From-SVN: r263135
2018-07-31[19/46] Make vect_dr_stmt return a stmt_vec_infoRichard Sandiford1-129/+111
This patch makes vect_dr_stmt return a stmt_vec_info instead of a gimple stmt. Rather than retain a separate gimple stmt variable in cases where both existed, the patch replaces uses of the gimple variable with the uses of the stmt_vec_info. Later patches do this more generally. Many things that are keyed off a data_reference would these days be better keyed off a stmt_vec_info, but it's more convenient to do that later in the series. The vect_dr_size calls that are left over do still benefit from this patch. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vect_dr_stmt): Return a stmt_vec_info rather than a gimple stmt. * tree-vect-data-refs.c (vect_analyze_data_ref_dependence) (vect_slp_analyze_data_ref_dependence, vect_record_base_alignments) (vect_calculate_target_alignmentm, vect_compute_data_ref_alignment) (vect_update_misalignment_for_peel, vect_verify_datarefs_alignment) (vector_alignment_reachable_p, vect_get_data_access_cost) (vect_get_peeling_costs_all_drs, vect_peeling_hash_get_lowest_cost) (vect_peeling_supportable, vect_enhance_data_refs_alignment) (vect_find_same_alignment_drs, vect_analyze_data_refs_alignment) (vect_analyze_group_access_1, vect_analyze_group_access) (vect_analyze_data_ref_access, vect_analyze_data_ref_accesses) (vect_vfa_access_size, vect_small_gap_p, vect_analyze_data_refs) (vect_supportable_dr_alignment): Remove vinfo_for_stmt from the result of vect_dr_stmt and use the stmt_vec_info instead of the associated gimple stmt. * tree-vect-loop-manip.c (get_misalign_in_elems): Likewise. (vect_gen_prolog_loop_niters): Likewise. * tree-vect-loop.c (vect_analyze_loop_2): Likewise. From-SVN: r263134
2018-07-31[18/46] Make SLP_TREE_SCALAR_STMTS a vec<stmt_vec_info>Richard Sandiford1-16/+17
This patch changes SLP_TREE_SCALAR_STMTS from a vec<gimple *> to a vec<stmt_vec_info>. It's longer than the previous conversions but mostly mechanical. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_slp_tree::stmts): Change from a vec<gimple *> to a vec<stmt_vec_info>. * tree-vect-slp.c (vect_free_slp_tree): Update accordingly. (vect_create_new_slp_node): Take a vec<gimple *> instead of a vec<stmt_vec_info>. (_slp_oprnd_info::def_stmts): Change from a vec<gimple *> to a vec<stmt_vec_info>. (bst_traits::value_type, bst_traits::value_type): Likewise. (bst_traits::hash): Update accordingly. (vect_get_and_check_slp_defs): Change the stmts parameter from a vec<gimple *> to a vec<stmt_vec_info>. (vect_two_operations_perm_ok_p, vect_build_slp_tree_1): Likewise. (vect_build_slp_tree): Likewise. (vect_build_slp_tree_2): Likewise. Update uses of SLP_TREE_SCALAR_STMTS. (vect_print_slp_tree): Update uses of SLP_TREE_SCALAR_STMTS. (vect_mark_slp_stmts, vect_mark_slp_stmts_relevant) (vect_slp_rearrange_stmts, vect_attempt_slp_rearrange_stmts) (vect_supported_load_permutation_p, vect_find_last_scalar_stmt_in_slp) (vect_detect_hybrid_slp_stmts, vect_slp_analyze_node_operations_1) (vect_slp_analyze_node_operations, vect_slp_analyze_operations) (vect_bb_slp_scalar_cost, vect_slp_analyze_bb_1) (vect_get_constant_vectors, vect_get_slp_defs) (vect_transform_slp_perm_load, vect_schedule_slp_instance) (vect_remove_slp_scalar_calls, vect_schedule_slp): Likewise. (vect_analyze_slp_instance): Build up a vec of stmt_vec_infos instead of gimple stmts. * tree-vect-data-refs.c (vect_slp_analyze_node_dependences): Change the stores parameter for a vec<gimple *> to a vec<stmt_vec_info>. (vect_slp_analyze_instance_dependence): Update uses of SLP_TREE_SCALAR_STMTS. (vect_slp_analyze_and_verify_node_alignment): Likewise. (vect_slp_analyze_and_verify_instance_alignment): Likewise. * tree-vect-loop.c (neutral_op_for_slp_reduction): Likewise. (get_initial_defs_for_reduction): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorize_fold_left_reduction): Likewise. * tree-vect-stmts.c (vect_prologue_cost_for_slp_op): Likewise. (vect_model_simple_cost, vectorizable_shift, vectorizable_load) (can_vectorize_live_stmts): Likewise. From-SVN: r263133
2018-07-31[14/46] Make STMT_VINFO_VEC_STMT a stmt_vec_infoRichard Sandiford1-6/+5
This patch changes STMT_VINFO_VEC_STMT from a gimple stmt to a stmt_vec_info and makes the vectorizable_* routines pass back a stmt_vec_info to vect_transform_stmt. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_stmt_vec_info::vectorized_stmt): Change from a gimple stmt to a stmt_vec_info. (vectorizable_condition, vectorizable_live_operation) (vectorizable_reduction, vectorizable_induction): Pass back the vectorized statement as a stmt_vec_info. * tree-vect-data-refs.c (vect_record_grouped_load_vectors): Update use of STMT_VINFO_VEC_STMT. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise, accumulating the inner phis that feed the STMT_VINFO_VEC_STMT as stmt_vec_infos rather than gimple stmts. (vectorize_fold_left_reduction): Change vec_stmt from a gimple stmt to a stmt_vec_info. (vectorizable_live_operation): Likewise. (vectorizable_reduction, vectorizable_induction): Likewise, updating use of STMT_VINFO_VEC_STMT. * tree-vect-stmts.c (vect_get_vec_def_for_operand_1): Update use of STMT_VINFO_VEC_STMT. (vect_build_gather_load_calls, vectorizable_bswap, vectorizable_call) (vectorizable_simd_clone_call, vectorizable_conversion) (vectorizable_assignment, vectorizable_shift, vectorizable_operation) (vectorizable_store, vectorizable_load, vectorizable_condition) (vectorizable_comparison, can_vectorize_live_stmts): Change vec_stmt from a gimple stmt to a stmt_vec_info. (vect_transform_stmt): Update use of STMT_VINFO_VEC_STMT. Pass a pointer to a stmt_vec_info to the vectorizable_* routines. From-SVN: r263129
2018-07-31[13/46] Make STMT_VINFO_RELATED_STMT a stmt_vec_infoRichard Sandiford1-15/+16
This patch changes STMT_VINFO_RELATED_STMT from a gimple stmt to a stmt_vec_info. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (_stmt_vec_info::related_stmt): Change from a gimple stmt to a stmt_vec_info. (is_pattern_stmt_p): Update accordingly. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Likewise. (vect_record_grouped_load_vectors): Likewise. * tree-vect-loop.c (vect_determine_vf_for_stmt): Likewise. (vect_fixup_reduc_chain, vect_update_vf_for_slp): Likewise. (vect_model_reduction_cost): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction, vectorizable_induction): Likewise. * tree-vect-patterns.c (vect_init_pattern_stmt): Likewise. Return the stmt_vec_info for the pattern statement. (vect_set_pattern_stmt): Update use of STMT_VINFO_RELATED_STMT. (vect_split_statement, vect_mark_pattern_stmts): Likewise. * tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Likewise. (vect_detect_hybrid_slp, vect_get_slp_defs): Likewise. * tree-vect-stmts.c (vect_mark_relevant): Likewise. (vect_get_vec_def_for_operand_1, vectorizable_call): Likewise. (vectorizable_simd_clone_call, vect_analyze_stmt, new_stmt_vec_info) (free_stmt_vec_info, vect_is_simple_use): Likewise. From-SVN: r263128
2018-07-31[06/46] Add vec_info::add_stmtRichard Sandiford1-2/+2
This patch adds a vec_info function for allocating and setting stmt_vec_infos. It's the start of a long process of removing the global stmt_vec_info array. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (stmt_vec_info): Move typedef earlier in file. (vec_info::add_stmt): Declare. * tree-vectorizer.c (vec_info::add_stmt): New function. * tree-vect-data-refs.c (vect_create_data_ref_ptr): Use it. * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Likewise. (vect_create_epilog_for_reduction, vectorizable_reduction): Likewise. (vectorizable_induction): Likewise. * tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Likewise. * tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise. (vectorizable_simd_clone_call, vectorizable_store): Likewise. (vectorizable_load): Likewise. * tree-vect-patterns.c (vect_init_pattern_stmt): Likewise. (vect_recog_bool_pattern, vect_recog_mask_conversion_pattern) (vect_recog_gather_scatter_pattern): Likewise. (append_pattern_def_seq): Likewise. Remove a check that is performed by add_stmt itself. From-SVN: r263121
2018-06-29tree-vect-data-refs.c (vect_analyze_data_ref_dependences): Assert ↵Richard Biener1-4/+5
compute_all_dependences succeeds. 2018-06-29 Richard Biener <rguenther@suse.de> * tree-vect-data-refs.c (vect_analyze_data_ref_dependences): Assert compute_all_dependences succeeds. * tree-vect-loop.c (vect_get_datarefs_in_loop): Fail early if we exceed --param loop-max-datarefs-for-datadeps. From-SVN: r262244
2018-06-25tree-vectorizer.h (struct vec_info_shared): New structure with parts split ↵Richard Biener1-14/+19
out from struct vec_info and loop_nest from... 2018-06-25 Richard Biener <rguenther@suse.de> * tree-vectorizer.h (struct vec_info_shared): New structure with parts split out from struct vec_info and loop_nest from struct _loop_vec_info. (struct vec_info): Adjust accordingly. (struct _loop_vec_info): Likewise. (LOOP_VINFO_LOOP_NEST): Adjust. (LOOP_VINFO_DATAREFS): Likewise. (LOOP_VINFO_DDRS): Likewise. (struct _bb_vec_info): Likewise. (BB_VINFO_DATAREFS): Likewise. (BB_VINFO_DDRS): Likewise. (struct _stmt_vec_info): Add dr_aux member. (DR_VECT_AUX): Adjust to refer to member of DR_STMTs vinfo. (DR_MISALIGNMENT_UNINITIALIZED): New. (set_dr_misalignment): Adjust. (dr_misalignment): Assert misalign isn't DR_MISALIGNMENT_UNINITIALIZED. (vect_analyze_loop): Adjust prototype. (vect_analyze_loop_form): Likewise. * tree-vect-data-refs.c (vect_analyze_data_ref_dependences): Compute dependences lazily. (vect_record_base_alignments): Use shared datarefs/ddrs. (vect_verify_datarefs_alignment): Likewise. (vect_analyze_data_refs_alignment): Likewise. (vect_analyze_data_ref_accesses): Likewise. (vect_analyze_data_refs): Likewise. * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Add constructor parameter for shared part. (vect_analyze_loop_form): Pass in shared part and adjust. (vect_analyze_loop_2): Pass in storage for the number of stmts. Move loop nest finding to the caller. Compute datarefs lazily. (vect_analyze_loop): Pass in shared part. (vect_transform_loop): Verify shared datarefs are unchanged. * tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Add constructor parameter for shared part. (vect_slp_analyze_bb_1): Pass in shared part and adjust. (vect_slp_bb): Verify shared datarefs are unchanged before transform. * tree-vect-stmts.c (ensure_base_align): Adjust for DR_AUX change. (new_stmt_vec_info): Initialize DR_AUX misalignment to DR_MISALIGNMENT_UNINITIALIZED. * tree-vectorizer.c (vec_info::vec_info): Add constructor parameter for shared part. (vec_info::~vec_info): Adjust. (vec_info_shared::vec_info_shared): New. (vec_info_shared::~vec_info_shared): Likewise. (vec_info_shared::save_datarefs): Likewise. (vec_info_shared::check_datarefs): Likewise. (try_vectorize_loop_1): Construct shared part live for analyses of a single loop for multiple vector sizes. * tree-parloops.c (gather_scalar_reductions): Adjust. From-SVN: r262009
2018-06-25tree-vect-data-refs.c (vect_find_stmt_data_reference): Modify DR for SIMD ↵Richard Biener1-80/+85
lane accesses here and mark DR with (void *)-1 aux. 2018-06-25 Richard Biener <rguenther@suse.de> * tree-vect-data-refs.c (vect_find_stmt_data_reference): Modify DR for SIMD lane accesses here and mark DR with (void *)-1 aux. (vect_analyze_data_refs): Remove similar code from here and simplify accordingly. From-SVN: r262008
2018-06-25tree-vect-data-refs.c (vect_check_gather_scatter): Fail for reverse storage ↵Richard Biener1-1/+3
order accesses rather than asserting they cannot... 2018-06-25 Richard Biener <rguenther@suse.de> Eric Botcazou <ebotcazou@libertysurf.fr> * tree-vect-data-refs.c (vect_check_gather_scatter): Fail for reverse storage order accesses rather than asserting they cannot happen here. * gnat.dg/sso9.adb: New testcase. * gnat.dg/sso9_pkg.ads: Likewise. From-SVN: r262007
2018-06-21tree-data-ref.c (dr_step_indicator): Handle NULL DR_STEP.Richard Biener1-80/+68
2018-06-21 Richard Biener <rguenther@suse.de> * tree-data-ref.c (dr_step_indicator): Handle NULL DR_STEP. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Avoid calling vect_mark_for_runtime_alias_test with gathers or scatters. (vect_analyze_data_ref_dependence): Re-order checks to deal with NULL DR_STEP. (vect_record_base_alignments): Do not record base alignment for gathers or scatters. (vect_compute_data_ref_alignment): Drop return value that is always true. Bail out early for gathers or scatters. (vect_enhance_data_refs_alignment): Bail out early for gathers or scatters. (vect_find_same_alignment_drs): Likewise. (vect_analyze_data_refs_alignment): Remove dead code. (vect_slp_analyze_and_verify_node_alignment): Likewise. (vect_analyze_data_refs): For possible gathers or scatters do not create an alternate DR, just check their possible validity and mark them. Adjust DECL_NONALIASED handling to not rely on DR_BASE_ADDRESS. * tree-vect-loop-manip.c (vect_update_inits_of_drs): Do not update inits of gathers or scatters. * tree-vect-patterns.c (vect_recog_mask_conversion_pattern): Also copy gather/scatter flag to pattern vinfo. From-SVN: r261834
2018-06-18Introduce DUMP_VECT_SCOPE macroDavid Malcolm1-24/+8
gcc/ChangeLog: * tree-vect-data-refs.c (vect_analyze_data_ref_dependences): Replace dump_printf_loc call with DUMP_VECT_SCOPE. (vect_slp_analyze_instance_dependence): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_analyze_data_refs_alignment): Likewise. (vect_slp_analyze_and_verify_instance_alignment (vect_analyze_data_ref_accesses): Likewise. (vect_prune_runtime_alias_test_list): Likewise. (vect_analyze_data_refs): Likewise. * tree-vect-loop-manip.c (vect_update_inits_of_drs): Likewise. * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. (vect_analyze_scalar_cycles_1): Likewise. (vect_get_loop_niters): Likewise. (vect_analyze_loop_form_1): Likewise. (vect_update_vf_for_slp): Likewise. (vect_analyze_loop_operations): Likewise. (vect_analyze_loop): Likewise. (vectorizable_induction): Likewise. (vect_transform_loop): Likewise. * tree-vect-patterns.c (vect_pattern_recog): Likewise. * tree-vect-slp.c (vect_analyze_slp): Likewise. (vect_make_slp_decision): Likewise. (vect_detect_hybrid_slp): Likewise. (vect_slp_analyze_operations): Likewise. (vect_slp_bb): Likewise. * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise. (vectorizable_bswap): Likewise. (vectorizable_call): Likewise. (vectorizable_simd_clone_call): Likewise. (vectorizable_conversion): Likewise. (vectorizable_assignment): Likewise. (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. * tree-vectorizer.h (DUMP_VECT_SCOPE): New macro. From-SVN: r261710
2018-06-08Convert dump and optgroup flags to enumsDavid Malcolm1-1/+1
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-01tree-vectorizer.h (vect_dr_stmt): New function.Richard Biener1-66/+67
2018-06-01 Richard Biener <rguenther@suse.de> * tree-vectorizer.h (vect_dr_stmt): New function. (vect_get_load_cost): Adjust. (vect_get_store_cost): Likewise. * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Use vect_dr_stmt instead of DR_SMTT. (vect_record_base_alignments): Likewise. (vect_calculate_target_alignment): Likewise. (vect_compute_data_ref_alignment): Likewise and make static. (vect_update_misalignment_for_peel): Likewise. (vect_verify_datarefs_alignment): Likewise. (vector_alignment_reachable_p): Likewise. (vect_get_data_access_cost): Likewise. Pass down vinfo to vect_get_load_cost/vect_get_store_cost instead of DR. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_hash_get_lowest_cost): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_find_same_alignment_drs): Likewise. (vect_analyze_data_refs_alignment): Likewise. (vect_analyze_group_access_1): Likewise. (vect_analyze_group_access): Likewise. (vect_analyze_data_ref_access): Likewise. (vect_analyze_data_ref_accesses): Likewise. (vect_vfa_segment_size): Likewise. (vect_small_gap_p): Likewise. (vectorizable_with_step_bound_p): Likewise. (vect_prune_runtime_alias_test_list): Likewise. (vect_analyze_data_refs): Likewise. (vect_supportable_dr_alignment): Likewise. * tree-vect-loop-manip.c (get_misalign_in_elems): Likewise. (vect_gen_prolog_loop_niters): Likewise. * tree-vect-loop.c (vect_analyze_loop_2): Likewise. * tree-vect-patterns.c (vect_recog_bool_pattern): Do not modify DR_STMT. (vect_recog_mask_conversion_pattern): Likewise. (vect_try_gather_scatter_pattern): Likewise. * tree-vect-stmts.c (vect_model_store_cost): Pass stmt_info to vect_get_store_cost. (vect_get_store_cost): Get stmt_info instead of DR. (vect_model_load_cost): Pass stmt_info to vect_get_load_cost. (vect_get_load_cost): Get stmt_info instead of DR. From-SVN: r261062
2018-05-29tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make sure to use ↵Richard Biener1-0/+4
non-pattern stmts for get_earlier_stmt arguments. 2018-05-29 Richard Biener <rguenther@suse.de> * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make sure to use non-pattern stmts for get_earlier_stmt arguments. * tree-vectorizer.h (get_earlier_stmt): Assert we do not get called on pattern stmts. (get_later_stmt): Likewise. From-SVN: r260896
2018-05-28re PR middle-end/85933 (FAIL: gcc.dg/sso/p8.c -O3 -finline-functions ↵Richard Biener1-1/+5
(internal compiler error)) 2018-05-28 Richard Biener <rguenther@suse.de> PR tree-optimization/85933 * tree-vect-data-refs.c (vect_record_base_alignments): Only look at stmts marked as vectorizable. From-SVN: r260848
2018-05-25tree-ssa-alias.h (refs_may_alias_p): Add tbaa_p bool parameter, defaulted to ↵Richard Biener1-22/+22
true. 2018-05-25 Richard Biener <rguenther@suse.de> * tree-ssa-alias.h (refs_may_alias_p): Add tbaa_p bool parameter, defaulted to true. (ref_maybe_used_by_stmt_p): Likewise. (stmt_may_clobber_ref_p): Likewise. (stmt_may_clobber_ref_p_1): Likewise. * tree-ssa-alias.c (refs_may_alias_p): Add tbaa_p bool parameter and pass it along. (ref_maybe_used_by_stmt_p): Likewise. (stmt_may_clobber_ref_p): Likewise. (stmt_may_clobber_ref_p_1): Likewise. * tree-vect-data-refs.c (vect_slp_analyze_node_dependences): Use the alias oracle to disambiguate DRs with stmts DR analysis couldn't handle. (vect_analyze_data_refs): Do not give up on not analyzable DRs for BB vectorization. Remove code truncating the dataref vector. From-SVN: r260757