[llvm-bugs] [Bug 37667] New: Clang miscompiles with optimization level -O1 and higher

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 3 11:12:35 PDT 2018


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

            Bug ID: 37667
           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

Clang miscompiles with optimization level -O1 and higher.
opt-bisect-limit points to X86 DAG->DAG Instruction Selection on function

Reproducer:
>$ cat repr.c
#include <stdio.h>

int a, b = 918, c;
unsigned d = 8089;

void foo() {
      a = (unsigned char)(c | b % d);
}

int main() {
  foo();
  printf("%d\n", a);
}

Error:
>$ clang -O0 repr.c ; ./a.out
150
>$ clang -O1 repr.c ; ./a.out
918

LLVM version:
clang version 7.0.0 (trunk 333836)
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/20180603/5eeec335/attachment-0001.html>


More information about the llvm-bugs mailing list