This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch GCC]Support constraint flags in loop structure.


Hi,
This patch adds support for constraint flags in loop structure.  Different to existing boolean flags which are set by niter analyzer, constraint flag is mainly set by consumers and affects certain semantics of niter analyzer APIs.  Currently niter APIs affected are number_of_iterations_exit* and their callers.  Constraint flags are added to support handling of possible infinite loops in GCC.  One typical usecase of constraint is in vectorizer, as described in patch's comment:

  /* ...
       1) Compute niter->assumptions by calling niter analyzer API and
	  record it as possible condition for loop versioning.
       2) Clear buffered result of niter/scev analyzer.
       3) Set constraint LOOP_C_FINITE assuming the loop is finite.
       4) Analyze data references.  Since data reference analysis depends
	  on niter/scev analyzer, the point is that niter/scev analysis
	  is done under circumstance of LOOP_C_FINITE constraint.
       5) Version the loop with assumptions computed in step 1).
       6) Vectorize the versioned loop in which assumptions is guarded to
	  be true.
       7) Update constraints in versioned loops so that niter analyzer
	  in following passes can use it.

     Note consumers are usually the loop optimizers and it is consumers'
     responsibility to set/clear constraints correctly.  Failing to do
     that might result in hard to track bugs in niter/scev analyzer.  */

Next patch will use constraint to vectorize possible infinite loop by versioning, I would also expect possible infinite loops (loops with assumptions) can be handled by more optimizers.  This patch itself doesn't change GCC behavior, bootstrap and test on x86_64.  Any comments?

Thanks,
bin

2016-07-25  Bin Cheng  <bin.cheng@arm.com>

	* cfgloop.h (struct loop): New field constraints.
	(LOOP_C_INFINITE, LOOP_C_FINITE): New macros.
	(loop_constraint_set, loop_constraint_clr, loop_constraint_set_p): New
	functions.
	* cfgloop.c (alloc_loop): Initialize new field.
	* tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions):
	Adjust niter analysis wrto loop constraints.

Attachment: loop-niter-costraint-20160726.txt
Description: loop-niter-costraint-20160726.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]