<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/106248>106248</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>
    In #105722 , we resolved the assertion failure in vectorization. However, I met this crash again with the following case:

```c
#include <stdint.h>
int a;
long b;
struct e {
  uint16_t f;
  uint64_t g;
  int32_t h
} static i = {65530};
void c(int d) {
  for (; a; a++)
    b *= d;
}
uint32_t j(struct e, uint16_t);
uint64_t k() { j(i, 0); }
uint32_t j(struct e, uint16_t) { c(i.f - 65528); }
```
The crash is: clang++: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && " VPlan cost model and legacy cost model disagreed"' failed.

The details can be found here: https://godbolt.org/z/8x48xsKs6
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF2v2zYM_TXMC9HApvyVBz_4JjNWrMMGrMgeL2RJsdUpUiDJubf99YPsJEu3vRQwEpMUDw-tQ_IQ9GiVaqF8gfKw4XOcnG8F91KP3OZZ1mwGJ7-2Hy0CsTwrayIE2uObQq-CM1clMU4KeQjKR-0snrg2s1eoLV6ViM7rbzwFtvize1NX5VP6RzyriHHSAYXnYUI-cm3xTcdpgTs5Y9ybtiMKHhSwDrIDZPffKlsfcbOJaSvMLBUC24cotY3bCdhPa1jbiBzYy2oZZ0ccHmaIfhYRFUJ98yDO2sa8eo14ehxbnVXxGnF8cmobGb1G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