[llvm-bugs] [Bug 37748] New: Clang produces incorrect code with -O2 and higher
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 8 05:34:17 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37748
Bug ID: 37748
Summary: Clang produces incorrect code with -O2 and higher
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: Vsevolod.Livinskij at frtk.ru
CC: llvm-bugs at lists.llvm.org
Created attachment 20413
--> https://bugs.llvm.org/attachment.cgi?id=20413&action=edit
Reproducer.
Clang miscompiles with -O2 and higher.
opt-bisect-limit points to CodeGen Prepare on function
Reproducer:
>$ cat func.c
extern long a;
extern long b;
extern unsigned short c;
extern long d;
extern short e;
void foo() {
a = (short)(e | (c & -32692));
if (c / d)
b = (e | (c & -32692)) > 0;
}
>$ cat driver.c
#include <stdio.h>
long a, b;
unsigned short c = 43589;
long d = 3;
short e;
void foo();
int main() {
foo();
printf("%ld\n", a);
}
Error:
>$ clang driver.c func.c ; ./a.out
-32700
>$ clang -O2 driver.c func.c ; ./a.out
32836
LLVM version:
clang version 7.0.0 (trunk 334268)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
--
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/20180608/bcfa02d7/attachment-0001.html>
More information about the llvm-bugs
mailing list