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

    <tr>
        <th>Summary</th>
        <td>
            SLP Vectorizer Options trigger Assertion in cost computation on `s390x`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dominik-steenken
      </td>
    </tr>
</table>

<pre>
    While running experiments with `csmith`, i ran into the following example (already reduced with `cvise`):
```C
static int c[][10];
short d;
long *e;
long f;
int g, k;
char h, i;
static int j[3];
void l();
static int *m() {
  short *n = &d;
  d = 0;
  for (; d <= 2;)
    if (*n)
      ;
    else
      return j;
  return &g;
}
void p() { l(); }
void l() {
  int *q;
  h = 0;
  for (; h <= 6; h++) {
    int **r = &q;
    *e = 4073709551615;
    *r = m();
    k = 0;
    for (; k <= 6; k++) {
      i = 2;
      for (; i <= 6; i++)
 **r |= c[k][h] ^= f;
    }
  }
}
```
 When compiling this with the options
```
  -O3 \
  -S \
  -w \
  -c \
  -o a.out \
 --target=s390x-ibm-linux \
  -march=z13 \
  -mllvm -slp-max-reg-size=256 \
  -mllvm -slp-vectorize-hor-store \
  -mllvm -slp-vectorize-non-power-of-2 \
  -mllvm -enable-tbaa=false \
```
The assertion `(Idx + EltsPerVector) <= BaseVF && "SK_ExtractSubvector index out of range"` fails in `llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::computeExtractCost`. This does not seem to be an issue on X86.

[repro.tar.gz](https://github.com/user-attachments/files/20672338/repro.tar.gz)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVVuPozYU_jXOyxER2AGSBx6SyUSqutKulO1u3yoDB_DE2KxtZrLz6yubkMt020pR7HPx5-_cDLdWtAqxIOmOpPsFH12nTVHrXihxiqxDVCdUi1LXP4vvnZAIZlRKqBbwPKARPSpn4U24D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