[llvm-commits] [Review Request][PATCH] Refactor BBVectorize: Initialize the MaxIter to
Hal Finkel
hfinkel at anl.gov
Thu Apr 5 08:34:28 PDT 2012
Ether,
This does not look right because v is changed as v *= 2 in each loop,
not incremented by one like an iteration count. You'd still need to
compare v and n separately.
Thanks again,
Hal
On Thu, 5 Apr 2012 22:36:28 +0800
Hongbin Zheng <etherzhhb at gmail.com> wrote:
> Hi Hal,
>
> This is a rather trivial patch which initialize the "MaxIter" with
> UINT_MAX, so that later in the loop invoking MaxIter we can replace
> v <= Config.VectorBits && (!Config.MaxIter || n <= Config.MaxIter)
>
> by
>
> v <= std::min(Config.VectorBits,Config.MaxIter)
>
> Any comment?
>
> best regards
> ether
>
> ---
> lib/Transforms/Vectorize/BBVectorize.cpp | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp
> b/lib/Transforms/Vectorize/BBVectorize.cpp
> index 7672d5c..5a714c8 100644
> --- a/lib/Transforms/Vectorize/BBVectorize.cpp
> +++ b/lib/Transforms/Vectorize/BBVectorize.cpp
> @@ -43,6 +43,7 @@
> #include "llvm/Target/TargetData.h"
> #include "llvm/Transforms/Vectorize.h"
> #include <algorithm>
> +#include <climits>
> #include <map>
> using namespace llvm;
>
> @@ -63,7 +64,7 @@ VectorBits("bb-vectorize-vector-bits",
> cl::init(128), cl::Hidden,
> cl::desc("The size of the native vector registers"));
>
> static cl::opt<unsigned>
> -MaxIter("bb-vectorize-max-iter", cl::init(0), cl::Hidden,
> +MaxIter("bb-vectorize-max-iter", cl::init(UINT_MAX), cl::Hidden,
> cl::desc("The maximum number of pairing iterations"));
>
> static cl::opt<unsigned>
> @@ -295,9 +296,8 @@ namespace {
> // Iterate a sufficient number of times to merge types of size
> 1 bit, // then 2 bits, then 4, etc. up to half of the target vector
> width of the // target vector register.
> - for (unsigned v = 2, n = 1;
> - v <= Config.VectorBits && (!Config.MaxIter || n <=
> Config.MaxIter);
> - v *= 2, ++n) {
> + for (unsigned v = 2, n = 1, e =
> std::min(Config.VectorBits,Config.MaxIter);
> + v <= e; v *= 2, ++n) {
> DEBUG(dbgs() << "BBV: fusing loop #" << n <<
> " for " << BB.getName() << " in " <<
> BB.getParent()->getName() << "...\n");
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list