aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgloop.h
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@arm.com>2016-07-29 15:44:00 +0000
committerBin Cheng <amker@gcc.gnu.org>2016-07-29 15:44:00 +0000
commit18767ebc32eaed40760aab394fe77d0815454efd (patch)
treea1a32cebdc504645bd7b6aa9f95e65a49b16c9a7 /gcc/cfgloop.h
parentf6c7a248d5eb50e3cfcf15e552c2be698ebea34b (diff)
downloadgcc-18767ebc32eaed40760aab394fe77d0815454efd.zip
gcc-18767ebc32eaed40760aab394fe77d0815454efd.tar.gz
gcc-18767ebc32eaed40760aab394fe77d0815454efd.tar.bz2
cfgloop.h (struct loop): New field constraints.
* 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. * cfgloopmanip.c (copy_loop_info): Copy constraints. * tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions): Adjust niter analysis wrto loop constraints. * doc/loop.texi (@node Number of iterations): Add description for loop constraints. From-SVN: r238876
Diffstat (limited to 'gcc/cfgloop.h')
-rw-r--r--gcc/cfgloop.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index dfc7525..5c202eb 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -188,6 +188,29 @@ struct GTY ((chain_next ("%h.next"))) loop {
of the loop can be safely evaluated concurrently. */
int safelen;
+ /* Constraints are generally set by consumers and affect certain
+ semantics of niter analyzer APIs. Currently the APIs affected are
+ number_of_iterations_exit* functions and their callers. One typical
+ use case of constraints is to vectorize possibly infinite loop:
+
+ 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 niter->assumptions computed in step 1).
+ 6) Vectorize the versioned loop in which niter->assumptions is
+ checked 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 down bugs in niter/scev consumers. */
+ unsigned constraints;
+
/* True if this loop should never be vectorized. */
bool dont_vectorize;
@@ -221,6 +244,32 @@ struct GTY ((chain_next ("%h.next"))) loop {
basic_block former_header;
};
+/* Set if the loop is known to be infinite. */
+#define LOOP_C_INFINITE (1 << 0)
+/* Set if the loop is known to be finite without any assumptions. */
+#define LOOP_C_FINITE (1 << 1)
+
+/* Set C to the LOOP constraint. */
+static inline void
+loop_constraint_set (struct loop *loop, unsigned c)
+{
+ loop->constraints |= c;
+}
+
+/* Clear C from the LOOP constraint. */
+static inline void
+loop_constraint_clear (struct loop *loop, unsigned c)
+{
+ loop->constraints &= ~c;
+}
+
+/* Check if C is set in the LOOP constraint. */
+static inline bool
+loop_constraint_set_p (struct loop *loop, unsigned c)
+{
+ return (loop->constraints & c) == c;
+}
+
/* Flags for state of loop structure. */
enum
{