[llvm-bugs] [Bug 37820] New: Clang miscompiles with optimization level -O1 and higher
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 16 03:16:19 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37820
Bug ID: 37820
Summary: Clang miscompiles with optimization level -O1 and
higher
Product: clang
Version: trunk
Hardware: PC
OS: Linux
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 20433
--> https://bugs.llvm.org/attachment.cgi?id=20433&action=edit
Reproducer.
Clang produces incorrect code with -O1 and higher.
Opt-bisect-limit points to X86 DAG->DAG Instruction Selection on function.
Reproducer:
>$ cat func.c
extern unsigned long a;
extern long b, c;
void foo() {
b = (unsigned int)(a >> ((-16384L & c) + 4503359447364223024));
}
>$ cat driver.c
#include <stdio.h>
unsigned long a = 10144615248613568396UL;
long b, c = -4503359447364216586L;
void foo();
int main() {
foo();
printf("%lu\n", b);
}
Error:
>$ clang -O0 driver.c func.c ; ./a.out
36040
>$ clang -O1 driver.c func.c ; ./a.out
3640036552
LLVM version:
clang version 7.0.0 (trunk 334837)
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/20180616/4258e6cb/attachment-0001.html>
More information about the llvm-bugs
mailing list