<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57120>57120</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
DCE breaks by adding redundant terms
</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, DCE breaks by adding a redundant term.
In the following example, the if statement always evaluates to false. LLVM (14) detects that and removes the dead code:
```c
#include <stdbool.h>
void DCEMarker0_();
void f(bool s, bool sc, bool r, bool cr, bool c) {
if ((((cr && sc && !r) || (c && !c)) && s && (!sc == !(r || r)))) {
DCEMarker0_();
}
}
```
Now, a redundant disjunction is inserted. LLVM is not able anymore to detect the dead code:
```c
#include <stdbool.h>
void DCEMarker0_();
void f(bool s, bool sc, bool r, bool cr, bool c) {
if (((((cr && sc && !r) || (c && !c)) && s && (!sc == !(r || (r || 0)))))) {
DCEMarker0_();
}
}
```
This is actually a regression: It worked fine up until LLVM 12.0.1. It has been an issue since LLVM 13.
This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/asrdfj6fs
(Might be related to #56711)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVE1zmzAQ_TXioikDwmD7wCGxk5nMJL0002tHSItRIiSPJOy4v74rsBOStMf2UGaNV9oPrfY9trHyVH-zPQTVgydsQ7ebG9o44M-eNifKpVRmRzl1IAcjuQk0gOtTSrItya6m952hoQPaWq3tMbrDC-_3GmK6aFAt9YEH6AHDuT7yk6dw4HrAPU-DpS3XHlJ6f__9gRK2yheEramEACKgveMYZSSW0NtDDMCUErikwkogxdW8FFJlk4jzmhXKCD1IoKTY-CAba3XakeJmHnWwSsaLP3D3DC77gTVgBaS4_uTUoimmoGOvJk28qu5VEzM1XoYsz7koPtiP8YSzCIfLCgVTXTTCcjfFbVCi-9wUU47Wc9ibCfPlMUuxRYmuuOUuWdwUdgmelxSfPzcgWslye-7Gq3Lp9bxLX-0x3nxOGKn802BEUNZQ5akyHlwAecYbd4xFgBsNiPKptw4iJSb0_zus_yXccz2bQ_9XCfDYRYw95SIMXOvTSIWdA-8Rf0SQ3gV6tHgKNlgZoMOeDiYoPbEhZ2mW5ml06jhOIACDrMB8fgDqEV44-xXpp0MFOuIgsRhFfQw8KP5hMG1sv1caHL152WtkmqNamedYVRfC3keCsVuUnUXy6JBat8PVT_xx72T7VLX-HQPZ6kHtuhBPdKBxnMnIXSRiWS1zBGOdQJ1XVVbkJVuWiawLuS7WPAkqaKh_O2rfD1qfDE7XH4pToRuaVNgeF1ofLn9f9s4-4UeDy7FfSNvbcpmzLOlqxpuF5HnWiGrVMrkshIB8tSr5WhQC2jbRvAHta1JeE8YMHKeWo07KbaJqljGWrXKWLxZ5vkjFUoqqFNkKv5Cm4IIsMui50mmsI3YtcfVYUjPsPBq18sG_GTmSYWcAxuMwPx9CZ1392Nme-wd-AqeT8fx6rP8X-QniwA">