<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/75995>75995</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
WRONG code SLP vectorizer? InstCombine?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JonPsson1
</td>
</tr>
</table>
<pre>
```
int printf(const char *, ...);
unsigned char a = 255;
unsigned int b = 0;
unsigned short fun(unsigned char g) { return g - 1; }
int main() {
for (short c = 0; c < 8; c++)
b |= fun(--a);
printf("%X\n", b);
}
```
fun() is doing arithmetic with 8 bits, and extending the result to 16 bits. 'b' ORs itself with this result, which could never be more than 8 bits. Yet, I see:
```
clang -target s390x-linux-gnu -march=z14 -O3 wrong1.i -o ./a.out; ./a.out
FFFF
clang -target s390x-linux-gnu -march=z14 -O3 wrong1.i -mllvm -slp-vectorize-hor=false -o ./a.out; ./a.out;
FF
```
It seems SLP vectorizer is generating an @llvm.vector.reduce.or.v8i16 which is later removed by InstCombine...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVMGOpDYQ_ZriUgJBuWngwGG6W0QTRZnV5pDkaKAaHIE9sk337H59ZOjtmd4oe1jJAkO9eu9VlUE6pwbNXEN-gPwUycWPxta_Gv3JOaOzqDX9lxr26W2lJ0iflPb4apX2Z6CyM9p57EZpEegJ6IhJkgBVIA4bersuehXqN6REECekPL-j7vFA3q7h9P8o3Gisx_OigcpH3gGoQigOaNkvViMOGGMG4oBQnD5yBZVZqsBwS9neI55NKKTcNLq7kXV7xHLdAh3WVX1LwmC5OAbwZiuO5X97gO9dAyKg_C_Ij3rdHrF9wD-6_a7_m0TwrRz2RukBpVV-nNmrDq_Kj1hiq7wLvFL3yG-edR9wfmS07JbJozeY7VdYgkBFC1Tgy2eHyjuezhuNH5W74QPXdVTdiJ1Zph41X9hiyzgby-hHqW-iCf7NK_oZHTOIpx9U0k1SDxh7aQf26ESVvsWT0stbPOgF41nabgRx-prtMH4ReLVGD1miMDaYADUyMYsPE3l_WGmbpmk-qv60zDxNlxljN73GF-68seorx6OxIE5nOTn-gZFvo7w7eaz82YfuzA7_-O0T3rltmOjAmq3061g1wi4NJpINk1jul44TY5NLqbL9bSTK4SQ9W7Q8mwv32H7BZ-380cyt0hy-yFU16mvRV6KSEddZkYpUVFRQNNYia8tdluZFRWlOYkc5c18Jyrs9FR1RpGpKSWREaUpU5JRQmZ2zfUlyV4m8lBJ2Kc9STcnq1tghUs4tXBd5VeXRJFue3PqXIdJ8xTUYjn5-imwdcuJ2GVyoVjnv3lm88hPXf35--f0X7EzP-F3HQDQfSwXRRIud6tH7VxcOHzVAzaD8uLRJZ2agJlDfbvGrNf9w54Ga1ZADalbD_wYAAP__dMCATw">