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

    <tr>
        <th>Summary</th>
        <td>
            DCE depends on datatype used (bool vs unsigned)
        </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>
    In some cases, the compiler's ability to eliminate dead code depends on the datatype used (bool vs unsigned).

LLVM detects that the if expression in the following code snippet evaluates to false and thus removes the dead code:

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

static void __attribute__ ((noinline)) DCEMarker0_() {printf("DCE2.0");}

void f(bool sc, bool s, bool c) {
    if ((sc && s && c && !(sc))) {
        DCEMarker0_();
    }
}
```

In the following snippet the datatype is switched to unsigned (the semantics stay the same). However, LLVM cannot eliminate the dead code anymore:

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

static void __attribute__ ((noinline)) DCEMarker0_() {printf("DCE2.0");}

void f(unsigned sc, unsigned s, unsigned c) {
    if ((sc && c && s && !(sc))) {
        DCEMarker0_();
    }
}
```

This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/4aEEeGToj (clang 14.0.0)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVE1v2zAM_TX2hZih2HE-Dj60SboVaG_FroFsybFaWTJMOWn260fJTZqmKNDTDjMUhTQp8ol8ZmnFsbg3gLaVUHGUGKUrcA0ptu2Uln2UzhF4qbRyR3AWpFatMtxJEJILchNe6qQRCNaEo4I77o6dhAGlgChdlNZq2CMMBtXOSBGlyyRi64jdjPvDw-9HCuJk5ZAicBfCqBrka9dLREWB1Ri7tlrbgzK7MTMa1XXSgdxzPRAo9BBrrlECN4JODAi9bO3eW5oLzFF2c4kgmrG3NapppkylB8oQZSt0QtmkibLNF1Z_v0t72JGKoCrYWyVgu-XO9aocnNxufUVoGauMVkZSMWjBerV55P2L7Nk22JcQzW-7XhlXBz0lhzRhJPgD2W00X19mC2nqU62x8m0cxbNUvQUdDwA9VOERC1YkzGgBnoTzmyidBI8R56cY_vmE3eM7e7wjPQtX1Q77_XWDT739QCmFgAflqoaYRa0-Mcrfw_uhbLmhspOX48dwFHnra5zAL3uQe0_oFQTCVdwY6y4I_YEgxJ9ja_v_lyjn0o1keVc_aN8izWf2_CvSPDVECGok0CdvofQEkAb2il9xafU2zWDz2mnqag9U0RfqLTTOdeibnN7R2lnqkXaJ7Xek_aHflG828ueTffa3rjSnYJNpwnyBlyOGWBSZWGZLHjvltCzoYpcT8TvTMB56XVwhUTS8yoTGMCla709_P7rePtOgJFUhDn5g3-WzWZ7FTVEzlstpVWfZokwXM1aymsm6rspMTBZ1lsaal1JjEeW3RA8jDxBCeKrk61gVKUtTNk8nk2wyzxcJF_lELJdZljNWibqMpow-L6UTj8OXKO6LAKkcdkhGrdDhu5FjuJ8M6Sg-H1xj--KpsS3HR36UvY5D_iLg_wt_q_Kt">