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

    <tr>
        <th>Summary</th>
        <td>
            [SLP] Failed the SLP relate to the cost model
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          vfdff
      </td>
    </tr>
</table>

<pre>
    * test: https://gcc.godbolt.org/z/qYMhMefzo
```
float bar(float* __restrict A, float* __restrict B, float T) {
  
    float K = 1;
 T += K * B[0];
    T += K * B[1];
    T += K * B[2];
    T += K * B[3];
    return T;
}
```

* llvm failed SLP default as  cost model, and gcc done
> record the assemble from llvm
```
bar(float*, float*, float):                            // @bar(float*, float*, float)
 ldp     s1, s2, [x1]
        fadd    s0, s1, s0
        ldp s3, s1, [x1, #8]
        fadd    s2, s2, s3
        fadd    s0, s0, s2
        fadd    s0, s0, s1
        ret
```
> SLP with extra option **-mllvm -slp-threshold=-3** , https://gcc.godbolt.org/z/75xT18xhd
```
bar(float*, float*, float): // @bar(float*, float*, float)
        ldr     q1, [x1]
        faddp   v1.4s, v1.4s, v1.4s
        faddp   s1, v1.2s
 fadd    s0, s0, s1
        ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklE1v4jwQxz_N5DIC-SWBcMgBHppLW6lSuTynyokdkpXB1HZYtp9-ZYeXtmK7qItQ7Hh-_jua_3iEc916q1QB2QKyZSJ63xpb7BvZNEll5K8C2By9ch74HFvvdw74HFgJrFzX9XhtZGW0Hxu7Bla-AStf_39sH1XzZoAsgcxhQo7_-NpoIzxWwgLL4zzIv7xY5bztao9zYP_htcDiHMAVsBnCdDEoIp5GPMbvEfgSKfATsUJgi7B2j0F1AdmCQLa8AIjXGHoDw25g-GfGKt_bLa7OizBdXs3W8cnmqPV-g43otJL4_PCEUjWi1x6FQ6yN87gxUumQI7GVuK5rlGarjvv5HVpVGyvRtwqFc2pTaYWNNZsofPXsjx69t-XdfBaq4ovfUCgIKblRbsiRlru43dEQdCw8IVscoiPnNEbHhZSRJJEcePKRCWqOX-KDUpgwnv9ZkV3OdvzLU8mR_DtDPzJW-eu-87vo8s_Ot6gO3go0O9-ZLcZ8zUebWA8jp3cj31rlWqMl8OWID3EMh91yWafZYUXzQyv_sQS-6fPZIBvHV_q10aEo9nScuoB9mlyFB7_3dMxOwPdcSWTB5YzPRKIKOqWcZWSa0qQt0krlOa0FYU2dNowqSukkY2yWVxmfMpJ0BSMsJSmdkEk2I3ScZ0oQRUjWTCithYCUqI3o9Dg4GpxJOud6VeR5nk4TLSql3ak52yJAo6pfO0iJ7px3l22-8zq28eeHJ8iWWA7NItz4UEpWaeEVehNXLi0j6a0uPpVK59u-GtdmA6yM_WEYRjtrfqjaAyvjNzpgZfzM3wEAAP__T2Sp6g">