<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVMlu2zAQ_Rr6Moghk14POsRxc2mCBjn0GpDSSGJLkw4XL_n6DmU7cdwWKFBBC6mZeZx580jl6kN5r32IoENICB16ZPwOggPrIoTkEXQDsdOBPEBCnTZGVzL2XipFVqxYccumxfGuTnMutK1MqhGYuAuxNloNOya-nMz9W9sItd7qmrDmebLPmHlwYHwBbLY8-gFdB2B8ycSKPnMai1UeF-TGxPISM_tSvtden8Hyxfg93ZCsR1l1Uhn8bJfK-Ugwl0v0cbPV9XoeY_IW9hmTUn9P6N3zTM779EAPVNKCcS2RacwBLG7Rg0J4Q-9gI6kjsUNo-t4YbTHXlCuj6I_KCJMoI0cLOsJOG5MhAlKwg1HOncxssjzgEa6vCpSXtupyP0PMIbjWMWLNJitao4txE5i4PRLUVtWwdbVyJg6db-nPGz2PT0_Sjb-6V1phCM-4MbLSts3JXfFGde507LLl5UUlbaK2L5ekX3q2GAN4XYNrqJwhXBL9zetW256qxiVbnyRp4TkRQZWre0Husn77SgnPd-GSKag6rH7mqokQvc4y1pHgtA3oqXySNmbacnSWZdDO_pGS3-ho1P41zMLU5lI-t9yH449NUtDYD7nvCQ6S4DnpdcqKP88XcEP7JI__cQeADH3kpUrPWvyLEAd1KeqFWMiBTLFzvjzw0SB5U15VSp1Lali5NU2M2Z4_NxvvfmBFbb7vT41Ag4kQs_GgK-czVCMlazVp1Hw6V2oxWUyLRonFSNXjig-MVGhCST1gnFvcHQ8eGhPXg__PQJe84LwYccFHgk_mQz7GeVMoIapCjScTZOMC11KbYcbJTRz4sodUqQ1kNDrE8GGUIejWIvYJU4aRNIPlw8P3R2gIJWTF1BiPuXhcuy1eHiqnvTbosyz7FH8BjRSYuw>53374</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM fails to detect/remove unreachable branch
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
y21
</td>
</tr>
</table>
<pre>
First issue here, so not sure if this is a duplicate, but
```c
#include <stdlib.h>
int divide(int x, int y) {
y += (y == 0);
if (y == 0) {
// unreachable
abort();
}
return x / y;
}
```
`y` can logically never be zero past the first line (if `y == 0`, then it will be set to 1), [yet the abort branch is still emitted](https://gcc.godbolt.org/z/MPPao4Koq). Replacing `abort();` with `__builtin_unreachable();` gets rid of it.
Originally found this in Rust code, where the `rhs == 0` check is [implicitly inserted due to the division](https://godbolt.org/z/fbxqs7s6n)
```rs
pub fn divide(x: u32, mut y: u32) -> u32 {
y += (y == 0) as u32;
x / y
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVMly2zAM_Rr6golGFqXYPugQx82lyTTTQ68ZioIltjTpcPGSry8o24nitjPVaCEF4AF4eFJj22P9oJwPoLyPCD06ZMU9eAvGBvDRIag1hF558gABbdxqJUUYvJoYWL5i-R27zU-nPO8LrozUsUVg_N6HVqsm6xn_cjYPd2UCtGqnWsKap80hYabFkRULYLPlyQ_oOAIrloyv6DGnNV-ldU5ujC_HmMmX6r32-gyWDlY80AnROBSyF43Gz3bRWBcIZpxiiJutrvM5DNEZOCRMKv29oHfPCznv2yNdIIUBbTsiU-sjGNyhgwbhDZ2FraCJhB5hPcxGK4Opp9QZRX90RphEGTkaUAH2SusE4ZGCLUxT7WRm1fKIJ7ihK2icMLJP8_QhheBGhYAtq1aUow9h6xm_OxHUSZl1tm2sDpl1Hb15o-vp-VnY8qt9pQwZfMetFlKZLhV3xRv1uVehT5aXlyYqHZR5GZM-9uwweHCqBbumdjIYE_3NqU6Zgaq1jaY9S9LA90gESdsOgtwn_Q6dEp7r_ZgpkD3KX6lrIkRtkoxVIDhlPDpqn6SNibYUnWTplTV_peQPOtbN4dXP_K1JrXweufOnF9vYwNp8yP1AcBB5kYrexKT4y34BN_SdpPV_fgEg_BA5VulFi_8Q4qStebvgCzEJRAHWj48_nmAtlPaJgBYDSprhg8ON3eH4GzlLZxKdrq9YoSnHJpN2Qxutd5fHzdbZnye44Q_jaVFxPisnfV1WEqucyljgrSzLnItFO8XZtFrwKp9hNdGiQe1rmhcrCoP700-K1jSXiaqLvCjyacGLKS-qeVaUOF_nDecyb8qqQlbmuKGmslRHGtfE1UNJTew8GbXywX8YhfeqM4hDOsIXMfTW1cdiOhnS1kPZvwGNJ4Im">