<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70421>70421</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            opt generates wrong code with "-passes=dse,newgvn"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Bazoka13
      </td>
    </tr>
</table>

<pre>
    *******************************************************************************
OS and Platform:
Ubuntu 20.04.4 LTS
*******************************************************************************
clang version:
$ clang -v
clang version 17.0.3
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/llvm-releases/llvm-17.0.3/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=dse,newgvn a.bc -o a.opt.bc
clang a.opt.bc -o a.out
 ./a.out
4
opt a.bc -o a0.opt.bc
clang a0.opt.bc -o a0.out
./a0.out 
-17
```

*******************************************************************************
Source Code:
```C
#include<stdio.h>
struct {
  int a;
} b;
short c;
unsigned int d() {
  int e[2][3][9] = {};
  unsigned char f;
 for (c = -17; c < 0; c = 4) {
    int g;
    for (; b.a >= 0;)
 for (f = 0;;) {
        int h;
        return e[f][f][0];
 }
  }
  return e[0][0][1];
}
int main() {
  d();
 printf("%d\n", c);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzklsGO4ygTx5-GXEq2MNhJfPChY3_5tNKsZqWelfa2woBtdmyIAHf3ztOvwI6Tnmn1aTRzmMgShvrXrwpcEJhzq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