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] limit vectorization to large enough trip-counts


The other patch I referred to in
http://gcc.gnu.org/ml/gcc/2007-01/msg00289.html:
This is a trivial patch that lets the user specify a minimum threshold for
the trip-count of a loop, below which vectorization should be avoided.
The new flag is: --param min-vect-loop-bound=X
The semantics is: If the number of vectorized iterations is less than or
equal to X - don't vectorize the loop. The default for X is 0.

In case the loop bound is known - we give up vectorization already at
compile time (if it's less than X). When the loop bound is unknown, we use
the guards that we already generate anyhow to control how many iterations
will be executed in the vectorized code, and how many in the remainder
scalar loop. The rum-time check we already generate is augmented to direct
execution to the scalar loop when n<=X instead of when n<=0.

Ideally we'd want to allow different thresholds for different kinds of
loops, rather than the same threshold for all loops (e.g. a loop with
aligned accesses might be profitable to vecotrize already from a smaller
trip-count than a loop with misaligned accesses). But even with this simple
patch, using it with --param min-vect-loop-bound=2 already helped to
improve performance of several benchmarks (i.e. allows benefitting from
vectorization speedups in some loops, and avoid degradations in other
loops).

Ideally2: what we really want is a cost model to replace the user specified
X. That is in the works. At least until then - this patch can be useful.

Was bootstrapped on powerpc-linux a couple months ago - I need to update to
current mainline and test. In the meantime, here it is.

Dorit

(See attached file: diff-min-loop-boun.txt)

Attachment: diff-min-loop-boun.txt
Description: Text document


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