On Tue, Jul 26, 2016 at 7:11 PM, Bin Cheng <bin.ch...@arm.com> wrote: > Hi, > This patch vectorizes possible infinite loops by versioning. It analyzes > loops considered for vectorization using loop constraint facility which was > introduced by previous patch; then vectorizes the loop with respect to > assumptions of loop niters information; at last, it sets constraint flags for > versioned loop so that niter analyzer in following optimizers can take > advantage of it. The patch also adds two tests. > > Bootstrap and test on x86_64. Any comments?
+ else if (integer_nonzerop (may_be_zero)) + { + niter = build_int_cst (TREE_TYPE (niter), 0); + *number_of_iterationsm1 = niter; + *number_of_iterations = niter; *number_of_iterations should be 1 here. Otherwise the patch looks ok to me. Thanks, RIchard. > Thanks, > bin > > 2016-07-25 Bin Cheng <bin.ch...@arm.com> > > 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/ChangeLog > 2016-07-25 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/57558 > * gcc.dg/vect/pr57558-1.c: New test. > * gcc.dg/vect/pr57558-2.c: New test.