[llvm-bugs] [Bug 38214] New: clang miscompiles with "-newgvn" at -O2 on valid code
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 18 15:19:40 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38214
Bug ID: 38214
Summary: clang miscompiles with "-newgvn" at -O2 on valid code
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: helloqirun at gmail.com
CC: llvm-bugs at lists.llvm.org
It happens at -O2 and -Os only. I have also tested r334040 and it miscompiles
as well.
$ clang-trunk -v
clang version 7.0.0 (trunk 337366)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
$ clang-trunk abc.c ; ./a.out
-16
$ clang-trunk -mllvm -enable-newgvn -O3 abc.c ; ./a.out
-16
$ clang-trunk -mllvm -enable-newgvn -O2 abc.c ; ./a.out
0
$ cat abc.c
int printf(char *, ...);
char a, b;
char c[1];
int d, e;
char(f)(char g, char h) { return g + h; }
int __attribute__((noinline)) i(long g) { return g ? 1 : 0; }
int main() {
char j = 0;
for (; j != 15; j = f(j, 5)) {
a = 0;
for (; a < 11; ++a)
if (a == b && j) {
e = 0;
for (; e < 8; e++)
if (i((long)c))
--d;
}
}
printf("%d\n", d);
}
--
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/20180718/a35ef6cf/attachment.html>
More information about the llvm-bugs
mailing list