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]

Re: [RFC] [autovect patch] Implement vectorization hints


On Friday 25 February 2005 01:27, Devang Patel wrote:
> This patch implements two #pragmas that developers can use to give
> hints to auto vectorization pass. These pragmas are inserted in the
> source file before the loop. They are effective only on the very next
> loop in the source file.

I was especially interested in understanding how you preserve the
information from the #pragma through the parser and the first steps
of the optimizers.  This is a "feature" we need for other pragmas
as well, such as pragmas to control unrolling, OpenMP, and the ia64
_USE_SF pragma.

If I understand your code correctly, you seem to mark the source
location of the pragma as the start of a range where the pragma is
"active".  The source location where the pragma stops to be active
(the "end" of the range where the pragma is active) is determined
in the vectorizer by looking at the last source location of a loop,
somehow.  You record the ranges in a varray (why not a VEC?) and
you do a linear search through the varray to look up ranges.

You don't check if there actually are any loops, and can not tell
what function the pragma was seen in, e.g. in this:

void bar ()
{
#pragma ivdeps
}

void foo ()
{
  int i = 0;
  /* Vectorize loop even though k is unknown.  */

  for (i = 0; i < 16; i++)
    A[i] = A[i + k];
}

the ivdeps pragma in bar() would apply to the loop in for().  In a
similar fashion, in the following code:

void foo ()
{
  int i = 0;
  /* Vectorize loop even though k is unknown.  */

#pragma ivdeps
  while (1)
    break;

  for (i = 0; i < 16; i++)
    A[i] = A[i + k];
}

the pragma would apply to the second loop, because the gimplifier
will collapse and remove the first loop.

Correct so far?  If so, then especially the ivdeps pragma is a sure
path to wrong code bugs.

In summary, I don't think this code is right way to go.

I was hoping for something more general, to be honest.  For the other
#pragma-needing projects there has to be interaction with the parser,
and it looks like you need that, too.  We have the new C parser now,
so it is actually possible, and the right time now, to think about a
general way to have this kind of pragmas.  IIRC Zack had some ideas
about how to do this...?

Gr.
Steven




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