[llvm-bugs] [Bug 43398] New: The vector stopped when the referencing order was changed

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 21 20:02:31 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43398

            Bug ID: 43398
           Summary: The vector stopped when the referencing order was
                    changed
           Product: libraries
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: fj8765ah at aa.jp.fujitsu.com
                CC: llvm-bugs at lists.llvm.org

The vector stopped when the referencing order was changed.
I think that NG.c can be vectorized.

$ clang -O3 OK.c -Rpass=vector -S -Rpass-analysis=vector
OK.c:14:7: remark: vectorized loop (vectorization width: 4, interleaved count:
2) [-Rpass=loop-vectorize]
      for(j=1 ; j<jmax-1 ; j++)
      ^
$ clang -O3 NG.c -Rpass=vector -S -Rpass-analysis=vector
NG.c:17:13: remark: loop not vectorized: value that could not be identified as
reduction is used outside the loop [-Rpass-analysis=loop-vectorize]
          + p[i  ][j  ]  // difference1
            ^

- OK.c
#define IMAX 257
#define JMAX 257

extern float  p[IMAX][JMAX];
extern float  q[IMAX][JMAX];
extern int imax, jmax;

void
foo()
{
  int i,j,k,n;

  for(i=1 ; i<imax-1 ; i++)
      for(j=1 ; j<jmax-1 ; j++)
        q[i][j]
          = p[i+1][j  ]
          + p[i  ][j+1]  // Reference1
          + p[i  ][j  ]  // Reference2
          ;

}

- NG.c
#define IMAX 257
#define JMAX 257

extern float  p[IMAX][JMAX];
extern float  q[IMAX][JMAX];
extern int imax, jmax;

void
foo()
{
  int i,j,k,n;

  for(i=1 ; i<imax-1 ; i++)
      for(j=1 ; j<jmax-1 ; j++)
        q[i][j]
          = p[i+1][j  ]
          + p[i  ][j  ]  // Reference2
          + p[i  ][j+1]  // Reference1
          ;

}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190922/c774f6c4/attachment.html>


More information about the llvm-bugs mailing list