<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109528>109528</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion failed in Vectorize
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cardigan1008
</td>
</tr>
</table>
<pre>
When I compiled this code with O2 flag, it crashed:
```c
#include <stdint.h>
static uint64_t
safe_sub_func_uint64_t_u_u(uint64_t ui1, uint64_t ui2)
{
return ui1 - ui2;
}
long a;
static int8_t c;
void b(long d, int f) {
int e = 0;
for (; e < 64; e++)
if (e - f)
a |= e >> f;
else
a |= d & e;
}
uint32_t g() {
b(6, c);
for (;; c = safe_sub_func_uint64_t_u_u(c, 4))
;
}
```
The crash is:
```
clang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7383: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && " VPlan cost model and legacy cost model disagreed"' failed.
```
Details can be found here: https://godbolt.org/z/7733x1hvP
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VF2v2jgQ_TXmZXRRGEMSHvIA4UZaqVIrbXX7iBzbSbwyNrIdtu2vX00CNHd7VRQRz4ePz8ycWMRoeqd1xXZHtjutxJgGHyopgjK9cJssK1etVz-qb4N28BdIf7kaqxWkwUSQXmn416QBPiN0VvQMazAJZBBx0IrxA8tOLHv859n8yLuN3DhpR6WB8TomZVxaD4y_zuGYRDISRuNSvj2nu1N0-hzH9tyNTp4fsfN4HhmWDxNGsyEmCxsZ7u-nFsd5ARB0GoOjbHiZcvjxkXOaF9a7HsTTf6dkXCrPCeTTf_NGQcuwnPLV1AWXoGO4h8V55KNaT5A9twJ0PgDDkvHjFKwh305rhsfpufMG01GahpcJ97GbfgJYURMs7X9l_BW6BT6AtlF_mK-AYQ7697qpcxzPCXpi9r4KqjOnEiXR-KgOoi-nOv84LkkgWwJZlvM7madulmL6OuhZZmDiL529z5RWuJ7xAzBsgveJYWPt7fJyDf4fLR8mvUzLsPkahIudD5fIsHnTMvlgfmqGzSfvr097La9Xxg8FLzlBTwj8wPjhkSGS8a4RZCyiS4wp44sVzukwR-mzGpM-6pjemrnlBH6IUQdKBqoJS4rPyOtvRqWBekxt_qR7IX-8NQ9vUbOihqsVrvYuCePiQSlDQML-bS5XazojJxaRYdnrRGQaHz44YhpPDbWPqU7fafk5mJ6qmQdHCiIRMUR4IxiQPia4eKUtCKfATtyWXmWi6IPWiiEyLKATdKOs_zDsk07C2AhSOGg1dH50CgYdNDVpSOk6SQAbhk3vVettWvvQM2x-MmyKgvPvm-H2ZaUqrvZ8L1a62hSY77Hc8nw1VEKg0tlO78qu2MhWl1vZ7ou23LRix7s8W5kKM9xme9xstphxXGdZXugu30vkXGZZx7aZvghj1zRwOntlYhx1tcn2OyxXVrTaxumORZxViUjXbagmQbZjH9k2syam-AsimWSni3nesTst9DD3DIyDpzBXY7DV_5ph0jC2a-kvC62__wImniT4O9Vbhf8FAAD__xTWylQ">