<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - The vector stopped when the referencing order was changed"
   href="https://bugs.llvm.org/show_bug.cgi?id=43398">43398</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The vector stopped when the referencing order was changed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>fj8765ah@aa.jp.fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
          ;

}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>