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

    <tr>
        <th>Summary</th>
        <td>
            DCE affected by applying De Morgan's law
        </td>
    </tr>

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

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

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

<pre>
    Sometimes the compiler's ability to detect and eliminate dead code is affected by applying De Morgan's law. 

In the following snippet, the compiler detects the dead code and thus removes it:

```c
#include <stdio.h>
#include <stdbool.h>

void DCEMarker0_();

void f(bool x, bool x5, bool c) {
    if ((((x && !x) || !(x || x5 || !c)) && (!c && 1) == !x5)) {
        DCEMarker0_();
    }
}
```

Now, DeMorgan's law is applied. However, LLVM (14) is not able anymore to detect and eliminate the dead code:

```c
#include <stdio.h>
#include <stdbool.h>

void DCEMarker0_();

void f(bool x, bool x5, bool c) {
    if ((((x && !x) || !(x || x5 || !c)) && !(c || 0) == !x5)) {
        DCEMarker0_();
    }
}
```

This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/56Ev77x8s

(Might be related to #57120)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVE2PmzAQ_TXmYhWBCZgcOOyGVK206aWrXiuDJ8FdgxF2vvrrO4awm2S1Uk89FQ3g8Yxn3nieXRl5Lr6bFpxqwVLXAK1N2ysNA2HcUlEprdyZOkMlOKgdFZ2koFWrOuEAJ4XEFRKoQuftFj1A0upMRd_rs-p2tAS6McNOdGM8LY4hJVFJoofp-7Ubk26N1ubo_W2n-h4cYasbNJf0E8S3rB6Na_aWDtCaA1agHEkerhOQLJqkvugsUV2t97iYJCvrpDJhQ5L1B9bKGH1tH78HoyQtV-uNGF5giH4SlhO2JMnjO6ctmnwIevIFTaP0dVjjKkr4ZRnFR23pGOwiJ9QyFPzFp8l5heLVyTqpp_TK4IOOrvPK3E_OajyakhJlDJrO3tco_PNxed5KeHmp9XUw7_P1HnwzR19sCbcUGMmCBFEgQ_rFHOHg6baiT08_Nh5wvPCQ0KkzSLhK-z6fWzPAhzy8YcV_BtwxwLvWs0P0Txnw3GAba9FRoa2hFVAL0NGDEnfHfjWf8_Wp19jpgWrVvWAnaeNcb31L2WeUncGGaBcin1D7jW-arQ-cn3J703OWb9SucT7jAFr4Wwm5g81Necz8FgRQxFkWZSnjWRbIIpHLZCkCp5yGAkv_y9ss2A-6uIOo8EaqQry5UNH6MP8-9YP5hSFRVdbuwXrwPOaLoCnyRNTIE14lfLFIoyQWIk1jCcBiLiFmgRYVaFuQ9JEw1oE_QhgCxyQtA1WwiLEoj7OYsSxahBnPt3wphJBVlcq0IosIWqF06HH4vQuGYoRU7XcWjVpZZ9-Mwlq16wDGdBhf7F1jhuK5Ma2wG3GGQQdj_mLE_wcxTsW4">