https://bugs.llvm.org/show_bug.cgi?id=37060
Bug ID: 37060
Summary: Clang miscompiles with -O1.
(X86_DAG->DAG_Instruction_Selection_on_function)
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: vsevolod.livins...@frtk.ru
CC: llvm-bugs@lists.llvm.org
Clang miscompiles testcase starting from optimization level -O1. opt-bisect
points to X86_DAG->DAG_Instruction_Selection_on_function.
Reproducer:
>$ cat main.c
#include <stdio.h>
const int b = 1545269876;
const int c = -1355305896;
const int * d = &(b);
int e = -1421384539;
extern void tf_0_foo();
int main () {
tf_0_foo ();
printf("%d\n", e);
return 0;
}
>$ cat func.c
extern const int tf_0_var_6;
extern const int c;
extern int e;
extern const int * d;
void tf_0_foo() {
short a = ~0 % c;
e = (unsigned char)(a ^ *d);
}
Error:
>$ clang -w -O0 main.c func.c ; ./a.out
139
>$ clang -w -O3 main.c func.c ; ./a.out
-117
LLVM version:
clang version 7.0.0 (trunk 329488)
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs