Commit Graph

320 Commits

Author SHA1 Message Date
Bin Cheng 57fa080bf6 re PR tree-optimization/77536 (Vectorizer not maintaining relationship of relative block frequencies in absence of real profile data)
PR tree-optimization/77536
	* tree-ssa-loop-manip.c (niter_for_unrolled_loop): New function.
	(tree_transform_and_unroll_loop): Use above function to compute the
	estimated niter of unrolled loop and use it when scaling profile.
	Also use count info rather than frequency if it's non-zero.
	* tree-ssa-loop-manip.h niter_for_unrolled_loop(): New declaration.
	* tree-vect-loop.c (scale_profile_for_vect_loop): New function.
	(vect_transform_loop): Call above function.

	gcc/testsuite
	* gcc.dg/vect/pr79347.c: Revise testing string.

From-SVN: r245754
2017-02-27 10:20:36 +00:00
Jakub Jelinek 2568d8a1f6 re PR tree-optimization/79284 (ICE on valid code at -O3 on x86_64-linux-gnu: verify_gimple failed)
PR tree-optimization/79284
	* tree-vectorizer.h (VECT_SCALAR_BOOLEAN_TYPE_P): Define.
	* tree-vect-stmts.c (vect_get_vec_def_for_operand,
	vectorizable_mask_load_store, vectorizable_operation,
	vect_is_simple_cond, get_same_sized_vectype): Use it instead
	of comparing TREE_CODE of a type against BOOLEAN_TYPE.
	* tree-vect-patterns.c (check_bool_pattern, search_type_for_mask_1,
	vect_recog_bool_pattern, vect_recog_mask_conversion_pattern): Likewise.
	* tree-vect-slp.c (vect_get_constant_vectors): Likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
	Remove redundant gimple_code (stmt) == GIMPLE_ASSIGN test after
	is_gimple_assign (stmt).  Replace another such test with
	is_gimple_assign (stmt).
testsuite/
	* gcc.c-torture/compile/pr79284.c: New test.

From-SVN: r245214
2017-02-06 20:15:36 +01:00
Jakub Jelinek ac6dbb1a40 re PR tree-optimization/79340 (Memory leaks in tree-vect-slp.c)
PR tree-optimization/79340
	* tree-vect-loop.c (vectorizable_reduction): Release
	vec_defs elements after safe_splicing them into other vectors.
	Formatting fixes.

From-SVN: r245171
2017-02-03 23:36:29 +01:00
Andrew Pinski cd8ae5edfe tree-vect-loop.c (vect_compute_single_scalar_iteration_cost): Pass stmt_info to record_stmt_cost.
2017-02-01  Andrew Pinski  <apinski@cavium.com>

        * tree-vect-loop.c (vect_compute_single_scalar_iteration_cost): Pass
        stmt_info to record_stmt_cost.
        (vect_get_known_peeling_cost): Pass stmt_info if known to
        record_stmt_cost.
        * config/aarch64/aarch64-protos.h (cpu_vector_cost): Split
        cpu_vector_cost field into
        scalar_int_stmt_cost and scalar_fp_stmt_cost.  Split vec_stmt_cost
        field into vec_int_stmt_cost and vec_fp_stmt_cost.
        * config/aarch64/aarch64.c (generic_vector_cost): Update for the
        splitting of scalar_stmt_cost and vec_stmt_cost.
        (thunderx_vector_cost): Likewise.
        (cortexa57_vector_cost): LIkewise.
        (exynosm1_vector_cost): Likewise.
        (xgene1_vector_cost): Likewise.
        (thunderx2t99_vector_cost): Improve after the splitting of the two
        fields.
        (aarch64_builtin_vectorization_cost): Update for the splitting of
        scalar_stmt_cost and vec_stmt_cost.

From-SVN: r245101
2017-02-01 10:30:50 -08:00
Alexandre Oliva d61d5fcd7f [bootstrap-O1] add initializers to avoid warnings at -O1
Building with the bootstrap-O1 configuration option fails to compile a
number of files due to AFAICT false-positive warnings about uses of
uninitialized variables.

This patch adds dummy initializers to silence them all.

for  gcc/ChangeLog

	* multiple_target.c (create_dispatcher_calls): Init e_next.
	* tree-ssa-loop-split.c (split_loop): Init border.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Init
	scalar_type.

From-SVN: r244086
2017-01-05 01:45:51 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 0d3ce69b79 re PR tree-optimization/78675 (ICE: verify_gimple failed (error: integral result type precision does not match field size of BIT_FIELD_REF))
2016-12-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/78675
	* tree-vect-loop.c (vectorizable_live_operation): For
	VECTOR_BOOLEAN_TYPE_P vectype use integral type with bitsize precision
	instead of TREE_TYPE (vectype) for the BIT_FIELD_REF.

	* gcc.c-torture/execute/pr78675.c: New test.
	* gcc.target/i386/pr78675-1.c: New test.
	* gcc.target/i386/pr78675-2.c: New test.

From-SVN: r243283
2016-12-06 10:21:13 +01:00
Yuri Rumyantsev 598eaaa2a2 Support non-masked epilogue vectoriziation
gcc/

2016-11-16  Yuri Rumyantsev  <ysrumyan@gmail.com>

	* params.def (PARAM_VECT_EPILOGUES_NOMASK): New.
	* tree-if-conv.c (tree_if_conversion): Make public.
	* * tree-if-conv.h: New file.
	* tree-vect-data-refs.c (vect_analyze_data_ref_dependences) Avoid
	dynamic alias checks for epilogues.
	* tree-vect-loop-manip.c (vect_do_peeling): Return created epilog.
	* tree-vect-loop.c: include tree-if-conv.h.
	(new_loop_vec_info): Add zeroing orig_loop_info field.
	(vect_analyze_loop_2): Don't try to enhance alignment for epilogues.
	(vect_analyze_loop): Add argument ORIG_LOOP_INFO which is not NULL
	if epilogue is vectorized, set up orig_loop_info field of loop_vinfo
	using passed argument.
	(vect_transform_loop): Check if created epilogue should be returned
	for further vectorization with less vf.  If-convert epilogue if
	required. Print vectorization success for epilogue.
	* tree-vectorizer.c (vectorize_loops): Add epilogue vectorization
	if it is required, pass loop_vinfo produced during vectorization of
	loop body to vect_analyze_loop.
	* tree-vectorizer.h (struct _loop_vec_info): Add new field
	orig_loop_info.
	(LOOP_VINFO_ORIG_LOOP_INFO): New.
	(LOOP_VINFO_EPILOGUE_P): New.
	(LOOP_VINFO_ORIG_VECT_FACTOR): New.
	(vect_do_peeling): Change prototype to return epilogue.
	(vect_analyze_loop): Add argument of loop_vec_info type.
	(vect_transform_loop): Return created loop.

gcc/testsuite/

2016-11-16  Yuri Rumyantsev  <ysrumyan@gmail.com>

	* lib/target-supports.exp (check_avx2_hw_available): New.
	(check_effective_target_avx2_runtime): New.
	* gcc.dg/vect/vect-tail-nomask-1.c: New test.

From-SVN: r242501
2016-11-16 08:22:39 -08:00
Richard Sandiford 29220523c1 Fix nb_iterations_estimate calculation in tree-vect-loop.c
vect_transform_loop has to reduce three iteration counts by
the vectorisation factor: nb_iterations_upper_bound,
nb_iterations_likely_upper_bound and nb_iterations_estimate.
All three are latch execution counts rather than loop body
execution counts.  The calculations were taking that into
account for the first two, but not for nb_iterations_estimate.

This patch updates the way the calculations are done to fix
this and to add a bit more commentary about what is going on.

gcc/
2016-11-15  Richard Sandiford  <richard.sandiford@arm.com>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

	* tree-vect-loop.c (vect_transform_loop): Protect the updates of
	all three iteration counts with an any_* test.  Use a single update
	for each count.  Fix the calculation of nb_iterations_estimate.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r242475
2016-11-16 10:18:25 +00:00
Bin Cheng c12176d716 tree-vect-loop.c (destroy_loop_vec_info): Handle cond_expr.
* tree-vect-loop.c (destroy_loop_vec_info): Handle cond_expr.
	(vect_is_simple_reduction): Swap cond_reduction by inversion.

From-SVN: r241810
2016-11-03 09:15:45 +00:00
Bin Cheng b4c32fe0dd tree-vect-loop.c (loop_niters_no_overflow): New func.
* tree-vect-loop.c (loop_niters_no_overflow): New func.
	(vect_transform_loop): Call loop_niters_no_overflow.  Pass the
	no-overflow information to vect_do_peeling_for_loop_bound and
	vect_gen_vector_loop_niters.

From-SVN: r241102
2016-10-13 11:09:23 +00:00
Bin Cheng a5e3d6146d tree-vect-loop-manip.c (adjust_vec_debug_stmts): Don't release adjust_vec automatically.
* tree-vect-loop-manip.c (adjust_vec_debug_stmts): Don't release
	adjust_vec automatically.
	(slpeel_add_loop_guard): Remove param cond_expr_stmt_list.  Rename
	param exit_bb to guard_to.
	(slpeel_checking_verify_cfg_after_peeling):
	(set_prologue_iterations):
	(create_lcssa_for_virtual_phi): New func which is factored out from
	slpeel_tree_peel_loop_to_edge.
	(slpeel_tree_peel_loop_to_edge):
	(iv_phi_p): New func.
	(vect_can_advance_ivs_p): Call iv_phi_p.
	(vect_update_ivs_after_vectorizer): Call iv_phi_p.  Directly insert
	new gimple stmts in basic block.
	(vect_do_peeling_for_loop_bound):
	(vect_do_peeling_for_alignment):
	(vect_gen_niters_for_prolog_loop): Rename to...
	(vect_gen_prolog_loop_niters): ...Rename from.  Change parameters and
	adjust implementation.
	(vect_update_inits_of_drs): Fix code style issue.  Convert niters to
	sizetype if necessary.
	(vect_build_loop_niters): Move to here from tree-vect-loop.c.  Change
	it to external function.
	(vect_gen_scalar_loop_niters, vect_gen_vector_loop_niters): New.
	(vect_gen_vector_loop_niters_mult_vf): New.
	(slpeel_update_phi_nodes_for_loops): New.
	(slpeel_update_phi_nodes_for_guard1): Reimplement.
	(find_guard_arg, slpeel_update_phi_nodes_for_guard2): Reimplement.
	(slpeel_update_phi_nodes_for_lcssa, vect_do_peeling): New.
	* tree-vect-loop.c (vect_build_loop_niters): Move to file
	tree-vect-loop-manip.c
	(vect_generate_tmps_on_preheader): Delete.
	(vect_transform_loop): Rename vectorization_factor to vf.  Call
	vect_do_peeling instead of vect_do_peeling-* functions.
	* tree-vectorizer.h (vect_do_peeling): New decl.
	(vect_build_loop_niters, vect_gen_vector_loop_niters): New decls.
	(vect_do_peeling_for_loop_bound): Delete.
	(vect_do_peeling_for_alignment): Delete.

From-SVN: r241099
2016-10-13 11:03:31 +00:00
Bin Cheng 328ba117ba tree-vect-loop.c (vect_analyze_loop_2): Check and skip loop if it has no enough iterations for LOOP_VINFO_PEELING_FOR_GAPS.
* tree-vect-loop.c (vect_analyze_loop_2): Check and skip loop if it
	has no enough iterations for LOOP_VINFO_PEELING_FOR_GAPS.

	gcc/testsuite
	* gcc.dg/vect/vect-98.c: Refine test case.
	* gcc.dg/vect/vect-strided-a-u8-i8-gap2.c: Increase niters.
	* gcc.dg/vect/vect-strided-u8-i8-gap2.c: Ditto.
	* gcc.dg/vect/vect-strided-u8-i8-gap4.c: Ditto.

From-SVN: r241097
2016-10-13 10:58:26 +00:00
Bin Cheng 37cf9f4f1c tree-vect-loop.c (vectorizable_live_operation): Support handling for live variable outside loop but not in lcssa form.
* tree-vect-loop.c (vectorizable_live_operation): Support handling
	for live variable outside loop but not in lcssa form.

From-SVN: r241096
2016-10-13 10:54:24 +00:00
Marek Polacek 8e4284d0b2 ipa-inline-analysis.c (find_foldable_builtin_expect): Use gimple_call_internal_p.
* ipa-inline-analysis.c (find_foldable_builtin_expect): Use
	gimple_call_internal_p.
	* ipa-split.c (find_return_bb): Likewise.
	(execute_split_functions): Likewise.
	* omp-low.c (dump_oacc_loop_part): Likewise.
	(oacc_loop_xform_head_tail): Likewise.
	* predict.c (predict_loops): Likewise.
	* sanopt.c (pass_sanopt::execute): Likewise.
	* tree-cfg.c (get_abnormal_succ_dispatcher): Likewise.
	* tree-parloops.c (oacc_entry_exit_ok_1): Likewise.
	* tree-stdarg.c (gimple_call_ifn_va_arg_p): Remove function.
	(expand_ifn_va_arg_1): Use gimple_call_internal_p.
	(expand_ifn_va_arg): Likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
	(optimize_mask_stores): Likewise.
	* tree-vect-stmts.c (vect_simd_lane_linear): Likewise.
	(vect_transform_stmt): Likewise.
	* tree-vectorizer.c (vect_loop_vectorized_call): Likewise.
	* tsan.c (instrument_memory_accesses): Likewise.

From-SVN: r240498
2016-09-26 15:50:13 +00:00
Bin Cheng 7e16ce79a4 re PR tree-optimization/77503 (ICE in vect_transform_stmt compiling postgresql)
PR tree-optimization/77503
	* tree-vect-loop.c (vectorizable_reduction): Record reduction
	code for CONST_COND_REDUCTION at analysis stage and use it at
	transform stage.
	* tree-vectorizer.h (struct _stmt_vec_info): New field.
	(STMT_VINFO_VEC_CONST_COND_REDUC_CODE): New macro.
	* tree-vect-stmts.c (new_stmt_vec_info): Initialize above new
	field.

	gcc/testsuite
	* gcc.dg/vect/pr77503.c: New test.

From-SVN: r240166
2016-09-15 16:31:35 +00:00
Richard Biener 027f10047b re PR tree-optimization/77286 (ICE in fold_convert_loc, at fold-const.c:2248 building 435.gromacs)
2016-08-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77286
	* tree-vect-loop.c (vect_analyze_loop_form_1): Do not modify
	the CFG here.
	(vect_transform_loop): Split exit edges of loop and scalar
	loop if required and at the appropriate time.

From-SVN: r239700
2016-08-23 13:58:19 +00:00
Alan Hayward 038000bd9d re PR tree-optimization/71752 (ICE in compute_live_loop_exits, at tree-ssa-loop-manip.c:229 w/ -O1 -ftree-vectorize)
2015-08-17  Alan Hayward <alan.hayward@arm.com>

	PR tree-optimization/71752
	* tree-vect-loop.c (vectorizable_reduction): Keep SLP operand ordering.
	* tree-vect-slp.c (vect_get_slp_defs): Handle null operands.

	PR tree-optimization/71752
	* gcc.dg/vect/pr71752.c: New

From-SVN: r239542
2016-08-17 15:31:44 +00:00
Bin Cheng 8eb414aa6c re PR tree-optimization/69848 (poor vectorization of a loop from SPEC2006 464.h264ref)
PR tree-optimization/69848
	* tree-vectorizer.h (enum vect_def_type): New condition reduction
	type CONST_COND_REDUCTION.
	* tree-vect-loop.c (vectorizable_reduction): Support new condition
	reudction type CONST_COND_REDUCTION.

	gcc/testsuite
	PR tree-optimization/69848
	* gcc.dg/vect/vect-pr69848.c: New test.

From-SVN: r239416
2016-08-12 14:58:20 +00:00
Bin Cheng 01d32b2b8b re PR tree-optimization/57558 (Loop not vectorized if iteration count could be infinite)
PR tree-optimization/57558
	* tree-vect-loop-manip.c (vect_create_cond_for_niters_checks): New
	function.
	(vect_loop_versioning): Support versioning with niter assumptions.
	* tree-vect-loop.c (tree-ssa-loop.h): Include header file.
	(vect_get_loop_niters): New parameter.  Reimplement to support
	assumptions in loop niter info.
	(vect_analyze_loop_form_1, vect_analyze_loop_form): Ditto.
	(new_loop_vec_info): Init LOOP_VINFO_NITERS_ASSUMPTIONS.
	(vect_estimate_min_profitable_iters): Use LOOP_REQUIRES_VERSIONING.
	Support loop versioning for niters.
	* tree-vectorizer.c (tree-ssa-loop-niter.h): Include header file.
	(vect_free_loop_info_assumptions): New function.
	(vectorize_loops): Free loop niter info for loops with flag
	LOOP_F_ASSUMPTIONS set if vectorization failed.
	* tree-vectorizer.h (struct _loop_vec_info): New field
	num_iters_assumptions.
	(LOOP_VINFO_NITERS_ASSUMPTIONS): New macro.
	(LOOP_REQUIRES_VERSIONING_FOR_NITERS): New macro.
	(LOOP_REQUIRES_VERSIONING): New macro.
	(vect_free_loop_info_assumptions): New decl.

	gcc/testsuite
	PR tree-optimization/57558
	* gcc.dg/vect/pr57558-1.c: New test.
	* gcc.dg/vect/pr57558-2.c: New test.

From-SVN: r238877
2016-07-29 15:48:25 +00:00
Ilya Enkovich d9157f1514 tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Update comment.
gcc/

	* tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Update
	comment.
	(vect_update_inits_of_drs): Likewise.
	(vect_create_cond_for_alias_checks): Likewise.
	* tree-vect-loop.c (vect_get_known_peeling_cost): Likewise.

From-SVN: r238466
2016-07-19 10:04:02 +00:00
Bin Cheng 6fa3d4b4a7 tree-vect-data-refs.c (vect_no_alias_p): New function.
* tree-vect-data-refs.c (vect_no_alias_p): New function.
	(vect_prune_runtime_alias_test_list): Call vect_no_alias_p to
	resolve alias checks which are known at compilation time.
	Truncate vector LOOP_VINFO_MAY_ALIAS_DDRS(loop_vinfo) if all
	alias checks are resolved.  Move dump info for too many runtime
	alias checks to here...
	* tree-vect-loop.c (vect_analyze_loop_2): ...From here.

	gcc/testsuite
	* gcc.dg/vect/vect-35-big-array.c: Refine comment and test.
	* gcc.dg/vect/vect-35.c: Ditto.
	* gcc.dg/vect/vect-alias-check-2.c: New test.

From-SVN: r238301
2016-07-13 15:06:40 +00:00
Alan Hayward 3c3ecf52a6 re PR debug/71667 (ICE in as_a, at is-a.h:192 w/ -g -O2 -ftree-vectorize)
2016-07-08  Alan Hayward  <alan.hayward@arm.com>

gcc/
	PR tree-optimization/71667
	* tree-vect-loop.c (vectorizable_live_operation): ignore DEBUG stmts

testsuite/
	PR tree-optimization/71667
	* gcc.dg/vect/pr71667.c: New

From-SVN: r238160
2016-07-08 08:50:24 +00:00
Richard Sandiford 4fb8ba9d35 [5/7] Move the fix for PR65518
This patch moves the fix for PR65518 to the code that checks whether
load-and-permute operations are supported.   If the group size is
greater than the vectorisation factor, it would still be possible
to fall back to elementwise loads (as for strided groups) rather
than fail vectorisation entirely.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.

gcc/
	* tree-vectorizer.h (vect_grouped_load_supported): Add a
	single_element_p parameter.
	* tree-vect-data-refs.c (vect_grouped_load_supported): Likewise.
	Check the PR65518 case here rather than in vectorizable_load.
	* tree-vect-loop.c (vect_analyze_loop_2): Update call accordignly.
	* tree-vect-stmts.c (vectorizable_load): Likewise.

From-SVN: r238037
2016-07-06 08:14:41 +00:00
Yuri Rumyantsev fafe9318b7 re PR tree-optimization/70729 (Loop marked with omp simd pragma is not vectorized)
gcc/

2016-06-29  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/70729
	* tree-ssa-loop-im.c (ref_indep_loop_p_1): Consider memory reference as
	independent in loops having positive safelen value.
	* tree-vect-loop.c (vect_transform_loop): Clear-up safelen value since
	it may be not valid after vectorization.

gcc/testsuite/

2016-06-29  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/70729
	* g++.dg/vect/pr70729.cc: New test.

From-SVN: r237844
2016-06-29 10:16:43 +00:00
Bin Cheng c7041a4fa3 tree-vect-loop.c (vect_create_epilog_for_reduction): Only insert gimple seq if it's not empty.
* tree-vect-loop.c (vect_create_epilog_for_reduction): Only
	insert gimple seq if it's not empty.

From-SVN: r237550
2016-06-17 09:17:39 +00:00
Alan Hayward 8dc3571219 re PR tree-optimization/71483 (g++ ICE at -O3 on valid code on x86_64-linux-gnu with “Floating point exception”)
2016-06-15  Alan Hayward  <alan.hayward@arm.com>

gcc/
	PR tree-optimization/71483
	* tree-vect-loop.c (vectorizable_live_operation): Pick correct index
	for slp

testsuite/
	PR tree-optimization/71483
	* g++.dg/vect/pr71483.c: New

From-SVN: r237483
2016-06-15 15:45:47 +00:00
Alan Hayward 8f482165c9 re PR tree-optimization/71439 (wrong code at -O3 in 32-bit and 64-bit mode on x86_64-linux-gnu)
2016-06-15  Alan Hayward  <alan.hayward@arm.com>

gcc/
	PR tree-optimization/71439
	* tree-vect-loop.c (vect_analyze_loop_operations): Additional check for
	live PHIs.

testsuite/
	PR tree-optimization/71439
	* gcc.dg/vect/pr71439.c: New

From-SVN: r237476
2016-06-15 10:53:01 +00:00
Alan Hayward 915794eb26 re PR tree-optimization/71416 (ICE at -O3 in 32-bit and 64-bit modes on x86_64-linux-gnu (vectorizable_live_operation))
2016-06-13  Alan Hayward  <alan.hayward@arm.com>

gcc/
	PR tree-optimization/71416
	* tree-vect-loop.c (vectorizable_live_operation): Let worklist have
	multiple entries

From-SVN: r237375
2016-06-13 11:07:35 +00:00
Alan Hayward 89851e4c13 re PR tree-optimization/71407 (ICE at -O3 in 32-bit and 64-bit modes on x86_64-linux-gnu (verify_gimple: integral result type precision does not match field size of BIT_FIELD_REF))
2016-06-10  Alan Hayward  <alan.hayward@arm.com>

gcc/
	PR tree-optimization/71407
	PR tree-optimization/71416
	* tree-vect-loop.c (vectorizable_live_operation): Use vectype for
	BIT_FIELD_REF type.

testsuite/
	PR tree-optimization/71407
	PR tree-optimization/71416
	* gcc.dg/vect/pr71407.c: New
	* gcc.dg/vect/pr71416-1.c: New
	* gcc.dg/vect/pr71416-2.c: New

From-SVN: r237288
2016-06-10 08:46:55 +00:00
Alan Hayward 15bdf5be1a tree-vect-data-refs.c (vect_analyze_data_refs): Remove debug newline.
2016-06-08  Alan Hayward  <alan.hayward@arm.com>

gcc/
	* tree-vect-data-refs.c (vect_analyze_data_refs): Remove debug newline.
	* tree-vect-loop-manip.c (slpeel_make_loop_iterate_ntimes): likewise.
	(vect_can_advance_ivs_p): likewise.
	(vect_update_ivs_after_vectorizer): likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): likewise.
	(vect_analyze_scalar_cycles_1): likewise.
	(vect_analyze_loop_operations): likewise.
	(report_vect_op): likewise.
	(vect_is_slp_reduction): likewise.
	(vect_is_simple_reduction): likewise.
	(get_initial_def_for_induction): likewise.
	(vect_transform_loop): likewise.
	* tree-vect-patterns.c (vect_recog_dot_prod_pattern): likewise.
	(vect_recog_sad_pattern): likewise.
	(vect_recog_widen_sum_pattern): likewise.
	(vect_recog_widening_pattern): likewise.
	(vect_recog_divmod_pattern): likewise.
	* tree-vect-slp.c (vect-build-slp_tree_1): likewise.
	(vect_analyze_slp_instance): likewise.
	(vect_transform_slp_perm_load): likewise.
	(vect_schedule_slp_instance): likewise.

From-SVN: r237198
2016-06-08 08:38:50 +00:00
Alan Hayward 3a2edf4cb8 [3/3] No need to vectorize simple only-live stmts
2016-06-03  Alan Hayward  <alan.hayward@arm.com>

[3/3] No need to vectorize simple only-live stmts

gcc/
	* tree-vect-stmts.c (vect_stmt_relevant_p): Do not vectorize non live
	relevant stmts which are simple and invariant.
	* tree-vect-loop.c (vectorizable_live_operation): Check relevance
	instead of simple and invariant

testsuite/
	* gcc.dg/vect/vect-live-slp-5.c: Remove dg check.

From-SVN: r237065
2016-06-03 13:04:01 +00:00
Alan Hayward b28ead45fe [2/3] Vectorize inductions that are live after the loop
2016-06-03  Alan Hayward  <alan.hayward@arm.com>

[2/3] Vectorize inductions that are live after the loop

gcc/
	* tree-vect-loop.c (vect_analyze_loop_operations): Allow live stmts.
	(vectorizable_reduction): Check for new relevant state.
	(vectorizable_live_operation): vectorize live stmts using
	BIT_FIELD_REF.  Remove special case for gimple assigns stmts.
	* tree-vect-stmts.c (is_simple_and_all_uses_invariant): New function.
	(vect_stmt_relevant_p): Check for stmts which are only used live.
	(process_use): Use of a stmt does not inherit it's live value.
	(vect_mark_stmts_to_be_vectorized): Simplify relevance inheritance.
	(vect_analyze_stmt): Check for new relevant state.
	* tree-vectorizer.h (vect_relevant): New entry for a stmt which is used
	outside the loop, but not inside it.

testsuite/
	* gcc.dg/tree-ssa/pr64183.c: Ensure test does not vectorize.
	* testsuite/gcc.dg/vect/no-scevccp-vect-iv-2.c: Remove xfail.
	* gcc.dg/vect/vect-live-1.c: New test.
	* gcc.dg/vect/vect-live-2.c: New test.
	* gcc.dg/vect/vect-live-3.c: New test.
	* gcc.dg/vect/vect-live-4.c: New test.
	* gcc.dg/vect/vect-live-5.c: New test.
	* gcc.dg/vect/vect-live-slp-1.c: New test.
	* gcc.dg/vect/vect-live-slp-2.c: New test.
	* gcc.dg/vect/vect-live-slp-3.c: New test.

From-SVN: r237064
2016-06-03 13:00:06 +00:00
Eric Botcazou de482e91f1 tree-vect-loop.c (vect_determine_vectorization_factor): Also compute the factor for live Phi nodes.
* tree-vect-loop.c (vect_determine_vectorization_factor): Also compute
	the factor for live Phi nodes.

From-SVN: r236999
2016-06-01 16:06:10 +00:00
Eric Botcazou a0dfeef505 tree-vect-loop.c (vect_determine_vectorization_factor): Also take into account live statements for mask producers.
* tree-vect-loop.c (vect_determine_vectorization_factor): Also take
	into account live statements for mask producers.

From-SVN: r236981
2016-06-01 10:35:30 +00:00
Jan Hubicka e5b1fae41b * tree-vect-loop.c (vect_transform_loop): Update likely bounds.
From-SVN: r236880
2016-05-30 14:12:46 +00:00
Jan Hubicka 6f2c0820ae tree-vect-loop.c (vect_analyze_loop_2): Use likely_max_stmt_executions_int.
* tree-vect-loop.c (vect_analyze_loop_2): Use
	likely_max_stmt_executions_int.

From-SVN: r236870
2016-05-30 08:19:24 +00:00
Richard Sandiford fce57248c8 Clean up PURE_SLP_STMT handling
The vectorizable_* routines had many instances of:

        slp_node || PURE_SLP_STMT (stmt_info)

which gives the misleading impression that we can have
!slp_node && PURE_SLP_STMT (stmt_info).  In this context
it's really enough to test slp_node on its own.

There are three cases:

      loop vectorisation only:
        vectorizable_foo called only with !slp_node

      pure SLP:
        vectorizable_foo called only with slp_node

      hybrid SLP:
        (e.g. a vector that's used in SLP statements and also in a reduction)
        - vectorizable_foo called once with slp_node for the SLP uses.
        - vectorizable_foo called once with !slp_node for the non-SLP uses.

Hybrid SLP isn't possible for stores, so I added an explicit assert
for that.

I also made vectorizable_comparison static, to make it obvious that
no other callers outside tree-vect-stmts.c could use it with the
!slp && PURE_SLP_STMT combination.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.

gcc/
	* tree-vectorizer.h (vectorizable_comparison): Delete.
	* tree-vect-loop.c (vectorizable_reduction): Remove redundant
	PURE_SLP_STMT check.
	* tree-vect-stmts.c (vectorizable_call): Likewise.
	(vectorizable_simd_clone_call): Likewise.
	(vectorizable_conversion): Likewise.
	(vectorizable_assignment): Likewise.
	(vectorizable_shift): Likewise.
	(vectorizable_operation): Likewise.
	(vectorizable_load): Likewise.
	(vectorizable_condition): Likewise.
	(vectorizable_store): Likewise.  Assert that we don't have
	hybrid SLP.
	(vectorizable_comparison): Make static.  Remove redundant
	PURE_SLP_STMT check.
	(vect_transform_stmt): Assert that we always have an slp_node
	if PURE_SLP_STMT.

From-SVN: r236642
2016-05-24 14:05:20 +00:00
Jan Hubicka cb6b1bdffe tree-vect-loop.c (vect_analyze_loop_2): Use also max_loop_iterations_int.
* tree-vect-loop.c (vect_analyze_loop_2): Use also 
	max_loop_iterations_int.

From-SVN: r236478
2016-05-19 15:50:56 +00:00
Bin Cheng 8340e4fcb8 re PR tree-optimization/69848 (poor vectorization of a loop from SPEC2006 464.h264ref)
PR tree-optimization/69848
	* tree-vect-loop.c (vectorizable_reduction): Don't factor
	comparison expr out of VEC_COND_EXPR for COND_REDUCTION.

From-SVN: r236447
2016-05-19 09:03:36 +00:00
Ilya Enkovich c4ec12434d re PR tree-optimization/71006 (ICE: verify_gimple failed (error: type mismatch in conditional expression) w/ -O1 -ftree-loop-vectorize)
gcc/

	PR tree-optimization/71006
	* tree-vect-loop.c (vect_determine_vectorization_factor): Don't
	consider COND_EXPR as a mask producer.

gcc/testsuite/

	PR tree-optimization/71006
	* gcc.dg/pr71006.c: New test.

From-SVN: r236171
2016-05-12 11:27:49 +00:00
Ilya Enkovich cca535a4c1 tree-vect-loop.c (vect_transform_loop): Fix nb_iterations_upper_bound computation for vectorized loop.
gcc/

	* tree-vect-loop.c (vect_transform_loop): Fix
	nb_iterations_upper_bound computation for vectorized loop.

gcc/testsuite/

	* gcc.target/i386/vect-unpack-2.c (avx512bw_test): Avoid
	optimization of vector loop.
	* gcc.target/i386/vect-unpack-3.c: New test.
	* gcc.dg/vect/vect-nb-iter-ub-1.c: New test.
	* gcc.dg/vect/vect-nb-iter-ub-2.c: New test.
	* gcc.dg/vect/vect-nb-iter-ub-3.c: New test.

From-SVN: r235639
2016-04-29 13:27:24 +00:00
Martin Liska 3e43b79cce Revert r234572 (aka PR testsuite/70577)
Revert
	2016-03-30  Jan Hubicka  <hubicka@ucw.cz>

	* tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic
	estimates here.
	* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Use also
	max_loop_iterations_int.
	(tree_unswitch_outer_loop): Likewise.
	* tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise.
	* tree-vect-loop.c (vect_analyze_loop_2): Likewise.

From-SVN: r234902
2016-04-12 13:38:46 +00:00
Jan Hubicka ba9c755f25 tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic estimates here.
* tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic
	estimates here.
	* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Use also
	max_loop_iterations_int.
	(tree_unswitch_outer_loop): Likewise.
	* tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise.
	* tree-vect-loop.c (vect_analyze_loop_2): Likewise.

From-SVN: r234572
2016-03-30 14:30:57 +00:00
Bin Cheng 446fd64280 tree-vect-loop.c (vect_analyze_loop_2): Fix wrong dump info by reporting malformed loop nest.
* tree-vect-loop.c (vect_analyze_loop_2): Fix wrong dump info by
	reporting malformed loop nest.

From-SVN: r234254
2016-03-16 10:57:34 +00:00
Martin Liska 2350426232 Skip properly debug stmt in optimize_mask_stores (PR
PR tree-optimization/70043
	* tree-vect-loop.c (optimize_mask_stores): Move iterator to
	previous statement if we see a debug statement.
	* gfortran.dg/vect/pr70043.f90: New test.

From-SVN: r233934
2016-03-03 10:08:09 +00:00
Richard Biener 6512bc9314 re PR tree-optimization/69720 (wrong code at -O3 on x86_64-linux-gnu)
2016-02-29  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69720
	* tree-vect-loop.c (get_initial_def_for_reduction): Avoid
	the adjustment_def path for possibly vectorized defs.
	(vect_create_epilog_for_reduction): Handle vectorized initial
	defs properly.

	* gcc.dg/vect/vect-outer-pr69720.c: New testcase.

From-SVN: r233803
2016-02-29 08:45:17 +00:00
Bin Cheng 0b1587d4b3 tree-vect-loop.c (vect_estimate_min_profitable_iters): Dump min_profitable_estimate, rather than min_profitable_iters.
* tree-vect-loop.c (vect_estimate_min_profitable_iters): Dump
	min_profitable_estimate, rather than min_profitable_iters.

From-SVN: r233604
2016-02-22 14:38:10 +00:00
Yuri Rumyantsev cdc23927ee re PR tree-optimization/69652 ([ICE] verify_ssa fail w/ -O2 -ffast-math -ftree-vectorize)
gcc/

2016-02-10  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/69652
	* tree-vect-loop.c (optimize_mask_stores): Move declaration of STMT1
	to nested loop, did source re-formatting, skip debug statements,
	add check on statement with volatile operand, remove dead scalar
	statements.

gcc/testsuite/

2016-02-10  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/69652
	* gcc.dg/torture/pr69652.c: New test.

From-SVN: r233275
2016-02-10 15:22:17 +00:00
Yuri Rumyantsev 2d4dc2233b re PR middle-end/68542 (10% 481.wrf performance regression)
gcc/

2016-02-02  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR middle-end/68542
	* config/i386/i386.c (ix86_expand_branch): Add support for conditional
	branch with vector comparison.
	* config/i386/sse.md (VI48_AVX): New mode iterator.
	(define_expand "cbranch<mode>4): Add support for conditional branch
	with vector comparison.
	* tree-vect-loop.c (optimize_mask_stores): New function.
	* tree-vect-stmts.c (vectorizable_mask_load_store): Initialize
	has_mask_store field of vect_info.
	* tree-vectorizer.c (vectorize_loops): Invoke optimaze_mask_stores for
	vectorized loops having masked stores after vec_info destroy.
	* tree-vectorizer.h (loop_vec_info): Add new has_mask_store field and
	correspondent macros.
	(optimize_mask_stores): Add prototype.

gcc/testsuite

2016-02-02  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR middle-end/68542
	* gcc.dg/vect/vect-mask-store-move-1.c: New test.
	* gcc.target/i386/avx2-vect-mask-store-move1.c: New test.

From-SVN: r233068
2016-02-02 09:46:26 +00:00