[LLVMbugs] [Bug 20421] New: Clang miscompilation due to loop vectorization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 23 16:26:28 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20421

            Bug ID: 20421
           Summary: Clang miscompilation due to loop vectorization
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: vonosmas at gmail.com
                CC: llvmbugs at cs.uiuc.edu, nlewycky at google.com,
                    qcolombet at apple.com
    Classification: Unclassified

Reproduces on x86_64 Linux with ToT Clang. I've ran a bisect and it pointed
to LLVM r212808, so this might be a recent bug.

$ cat tmp/optbug/a.cc
#include <stdio.h>

const int NUM = 28;
const int SCALE = 12;
const int ERROR_IDX = 24;

void ScaleArray2(int *a, int *h, int m) {
  for (int i = 0; i < NUM; ++i) {
    int original_delta = h[i];
    int scaled_delta = (original_delta * m) / SCALE;
    a[i] -= original_delta;
    a[i] += scaled_delta;
  }
}

int main() {
  int a[] = {-1662, 1623,  -882, 2348, 1639, 1957, 1480, 1866, 1835, 1529,
             1710,  1805,  1620, 1571, 1882, 1601, 1603, 1669, 1333, 2172,
             1745,  -1800, 1555, 1752, 1462, -654, 1522, 1744};
  int h[] = {138, 0, 300, 280, 0, 174, 0, 0, 103, 0, 0,   0, 0, 0,
             0,   0, 0,   0,   0, 220, 0, 0, 0,   0, -60, 0, 0, 0};
  printf("%d - %d + 4/12*%d = ", a[ERROR_IDX], h[ERROR_IDX], h[ERROR_IDX]);
  ScaleArray2(a, h, 4);
  printf("%d\n", a[ERROR_IDX]);
};
$ ./bin/clang++ -O2 tmp/optbug/a.cc && ./a.out
1462 - -60 + 4/12*-60 = 357915443

-- 
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/20140723/664e91db/attachment.html>


More information about the llvm-bugs mailing list