<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62273>62273</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crashes on "saddsat" while compiling for armv5te/armv6 thumb
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilyakurdyukov
</td>
</tr>
</table>
<pre>
On this code:
```c
void test(signed char *p, signed char add) {
int a = *p + add;
if (a > 127) a = 127;
if (a < -128) a = -128;
*p = a;
}
```
You can check in the [Compiler Explorer](https://godbolt.org/z/P5r3frM36), select the latest "armv8-a clang" (because armv7-a is not updated in CE), with these options: `-m32 -O2 -march=armv5te -mthumb`
Reproducible in the latest `android-ndk-r25c` (clang version 14.0.7).
This issue has been present since Сlang 10! `-march=armv6` is also affected.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU02PqzgQ_DXNpUVkmvCRA4eZMNxWb7Xayx6N3QneMRjZJm9nf_3KJLMTjZ4UBbUpV1d1NTIEc12YO6heoeozucXJ-c7YD_m-ef2xvbtbNjr90f1YME4moHKaoXwB0YN4gVrcf-pe35zRGDlEoHYn1qgm6RHoZQU64_OZ1BrohNC8PrjEySwRJULZ7xcQ6HVHlU-ICwK1CfOGBTWJ4H4hFb_EnTEvqP0C7tUT8t6p7FF-nTb9N3v38i-3oZILqonVO5o0EEaoXs9uXo1lj2__rNZ59lD1QO0U4xrSqGgAGq5Oj87Gg_NXoOFfoOH3ypcX_1tZA5324bBlFXdSK9MQEYikn29tLlFZuVyBKNkaWcktMKZ3TS7RBFxcxG3VMrJOws5vD86fJk6JMTC6NRq3JEEItcjnkjD_QZjP0qsJyj6xVZExn-O0zeP_ru__f_Dqnd6UGS1_Wv9UWQu5aO-Mzhf9nnuqFNQiCd1F4419MG7B4ngQhxTZ4Zn4z7RUJoSNcZIBR-YFV8-Bl4jBLIoRegEvxU5VCKDiLv9JdZ3amYDSBofycmEVWT-aZLor9ak8yYy7om5JVILqUzZ1-iTUqOpWiqZQojyqUWiSfKmpaYh0nZmOBJXiSIU4FoVoD5WqRVteSt3yqWlphKPgWRp7sPY2p1yz3UZXEzVlZuXINnx-V75LoHzcrgGOwpoQw9e1aKLl7rw7VF6GiQO6JaUfpNZBxpT7z8lYRrWvmlmueHEeH5EBDfsYcA8u27ztvu2eidM2HpSbgYbU9vHIV-_-ZhWBhl16ABp29f8FAAD__6WjOG0">