[llvm-bugs] [Bug 27619] New: [x86, loop vectorizer] cost model causes loop to not vectorize

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 3 10:26:22 PDT 2016


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

            Bug ID: 27619
           Summary: [x86, loop vectorizer] cost model causes loop to not
                    vectorize
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Re-filing the example from bug 27078 as a potential x86 cost model bug and/or
loop vectorizer bug. Note that this vectorizes for PPC but not x86 w/ AVX. But
I don't think the vectorization is being done optimally for PPC: no shuffles
should be needed if we treat everything as <12 x float>.

$ ./clang -O2 27078_orig.c -S -o - -emit-llvm -Rpass-analysis=loop-vectorize
-mavx
27078_orig.c:5:30: remark: the cost-model indicates that vectorization is not
beneficial [-Rpass-analysis=loop-vectorize]
      float* blurred_pixel = blurred_row[j];
                             ^
27078_orig.c:5:30: remark: the cost-model indicates that interleaving is not
beneficial [-Rpass-analysis=loop-vectorize]


typedef float Vector3_f[3];

void foo(Vector3_f* blurred_row, int width, float* pixel, float pixel_diff_avg)
{
    for (int j = 0; j < width; ++j, pixel += 3) {
      float* blurred_pixel = blurred_row[j];

      float pixel_diff[3];
      pixel_diff[0] = blurred_pixel[0] - pixel[0];
      pixel_diff[1] = blurred_pixel[1] - pixel[1];
      pixel_diff[2] = blurred_pixel[2] - pixel[2];

      pixel_diff[0] -= pixel_diff_avg;
      pixel_diff[1] -= pixel_diff_avg;
      pixel_diff[2] -= pixel_diff_avg;

      pixel[0] += pixel_diff[0];
      pixel[1] += pixel_diff[1];
      pixel[2] += pixel_diff[2];
    }
}

-- 
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/20160503/0c3e4a25/attachment.html>


More information about the llvm-bugs mailing list