[llvm-bugs] [Bug 37676] New: Intermittent bug in opt with -O3 -newgvn

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 4 04:29:37 PDT 2018


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

            Bug ID: 37676
           Summary: Intermittent bug in opt with -O3 -newgvn
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Vsevolod.Livinskij at frtk.ru
                CC: llvm-bugs at lists.llvm.org

Created attachment 20388
  --> https://bugs.llvm.org/attachment.cgi?id=20388&action=edit
Reproducer.

Intermittent bug in opt with -O3 -newgvn. 
It gives 2 variants of assembler for different compilations.
opt-bisect-limit points to "Global Value Numbering on function"
Reproducer:
>$ cat func.c
extern unsigned long long b, e, g;
extern const signed char a;
extern const unsigned c;
extern unsigned d, h;
extern signed char f, i;
extern unsigned *j;
extern unsigned long long *k;
extern signed char *l;
void foo() {
  if (*k <= (8 & -b * ((1 - 8ULL) * c) ?: ~i))
    f = 8 & -(b * ((1 - 8ULL) * c)) ?: i * d;
  e = g ? -(8 & -b * ((1 - 8ULL) * c) ?: i * d) : 0;
  if (!a) {
    *l = ~0 ? 8 & -(b * ((1 - 8ULL) * c)) ?: i * d : 2022409665839104;
    h = 8 & -(b * ((1ULL - 8) * c)) ? b * ((1 - 8ULL) * c) : 0;
  }
  if (8 & -(b * ((1ULL - 8) * c)) ? 0 : ~0)
    *j = b * ((1 - 8ULL) * c);
}
>$ cat driver.c
#include <stdio.h>
unsigned long long b, e, g;
const signed char a = 8;
const unsigned c = 92620;
unsigned d, h, m;
signed char f, i;
unsigned *j = &m;
unsigned long long *k = &e;
signed char *l;
void foo();
int main() {
  *j = 42;
  foo();
  printf("%u\n", *j);
}

Error:
>$ clang driver.c func.c
>$ ./a.out
0
>$ clang -O3 -Xclang -disable-llvm-optzns -emit-llvm -c -o func.bc func.c
>$ opt -O3 -o func.ll func.bc -newgvn
>$ clang -O3 -c -o func.o func.ll
>$ clang -O3 driver.c func.o
>$ ./a.out
42

LLVM version:
clang version 7.0.0 (trunk 333836)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /users/vlivinsk/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/20180604/1cde2cae/attachment.html>


More information about the llvm-bugs mailing list