Skip to content

opt generates wrong code with "correlated-propagation,dce,flattencfg" #71068

Closed
@Bazoka13

Description

@Bazoka13

OS and Platform:
Ubuntu 20.04.4 LTS


clang version 17.0.4
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/ctc/llvm-releases/llvm-17.0.4/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64


Command Lines:

clang -O3 -mllvm -disable-llvm-optzns -c -emit-llvm a.c -o a.bc
opt -passes=correlated-propagation,dce,flattencfg a.bc -o a.opt.bc
clang a.opt.bc -o a.out
 ./a.out
Floating point exception (core dumped)

Source Code:

int a;
void b() {
  int c;
  unsigned int d = 6;
  c = 3 % (((a || 0) < 0) - d || 0);
}
int main() { b(); }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions