<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111042>111042</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Assertion failed in VPlan.cpp:258
        </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 the code with -O2 flag, it crashed:

```c
#include <stdint.h>
static uint8_t c[] = {1};
void a();
long b(int h) {
 long d = 0;
  if (h < 0)
    return -1;
  int e = 0;
  for (int f = 0; f <= h; f++) {
    e++;
    d += f;
  }
  long a = d / e;
  return a;
}
void g();
uint8_t i() {
  uint16_t k[4];
 int f;
  for (; g + f < 4; f++)
    k[b(c[0] - 1)] = 5;
  for (; f; a(k))
    ;
  uint8_t *l[3][3], j;
  l[0][j] = c;
}
```

The crash is:
```
clang: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:258: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, bool): Assertion `(VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def) || !vputils::onlyFirstLaneUsed(Def) || (hasScalarValue(Def, VPLane(0)) && Data.VPV2Scalars[Def].size() == 1)) && "Trying to access a single scalar per part but has multiple scalars " "per part."' failed.
```

Details can be found here: https://godbolt.org/z/fTrKKha5E
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VV9vozgQ_zSTl1ERjCEhDzwkYSOtdqWrtL3c48qAAXcdO7JNTt1PfzKQlLSrk2jB8_c3v5mJuXOy00IUkO0hK1d88L2xRc1tIzuukzjOV5Vp3op_eqHxK9bmfJFKNOh7gbVpBP4rfY9PfxG2indAB5Qea8tdLxpgO4hLiG__1_H01POZmNS1GhqBwA7ON1L7qAf2ZVI7z72scZDa5z891hNCBFYibPYJbEpg-8n0am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