Skip to content

wrong code at -Os on x86_64-linux-gnu #62088

@zhendongsu

Description

@zhendongsu

It appears to be a regression from 15.0.0.

Compiler Explorer: https://godbolt.org/z/1cbebGh5o

% clangtk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 01b5c60d9ae09b666459330b62b78decdaae5d94)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
% 
% clangtk -O1 small.c; ./a.out
% 
% clangtk -Os small.c
% timeout -s 9 5 ./a.out
Killed
% 
% cat small.c
int a, d, e, f = -231418995, g, k;
short b;
static short c = 40;
int main() {
  unsigned h = 0;
  short i = 0;
 L:
  e = -(~i % ~(h & e) ^ ~f % 153578513);
  a = -1;
  f = h = -a;
  d = ~1260914024 ^ (e - 1824888657);
  if (d < 824855120) {
    i = d >> c;
    goto L;
  }
  short *l = &c;
  while (b)
    if (k)
      *l = g;
  return 0;
}

Metadata

Metadata

Assignees

Labels

llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions