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

            Bug ID: 42833
           Summary: Incorrect result with -O3 -march=skx
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

Clang produces incorrect result with -O3 -march=skx

Reproducer:
#include <stdio.h>

int b;
unsigned c[49];
int d[49];

void i() {
  for (int g = 32; g <= 48; g++) {
    d[g] -= c[g] + b;
    c[g] += c[g] + b;
    b -= b;
  }
}

int main() {
  for (int g = 0; g < 49; ++g)
    c[g] = 3;
  i();
  printf("%d\n", d[36]);
}

Error:
>$ clang -O3 -march=skx small.c ; ./a.out
0
>$ clang -O0 -march=skx small.c ; ./a.out
-3

LLVM version:
clang version 10.0.0 (trunk 367162)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to