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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV][LV] Subtract in reduction forcing fixed vector codegen
        </td>
    </tr>

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

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

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

<pre>
    In the following example, we have a summation loop.  One of the terms being contributed to the accumulator involves a subtraction.  This "-" appears to force us to pick a fixed vectorization factor instead of a scalable one. Simply changing the "-" to a "+" results in a scalable vector factor being chosen.

```
typedef struct {
    int x;
} s_t;

int example(s_t *a, s_t *b, int len) {
    int accum = 0;
    for (int i = 0; i < len; ++i) {
        accum += a[i].x - b[i].x;
        ;
    }
    return accum;
}
```

My guess is that this is some quirk of our cost model.  I haven't tried to chase it down just yet.  
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxcU01v4zYQ_TXUZRCBoszIOuhgxzAQoEWBpuh1QVEji7sUqZJDJ-6vLygrznYFApyH0bz54BsVo7k4xI7JI5OnQiWafOiWgGrGWPR-uHWvDmhCGL21_t24C-CHmheLTLzAO8KkrggKYppnRcY7sN4vJcAfDsGPayhhmCP0mIO1dxRMnwgHIL-6ldZpTlaRD2Dc1dsrxpWxp6B05iwB_ppMBCbEExMC1LKgCjETjD5ohLTai9E_QMFoPnCAK2rywfx7L2pU-k4fCdWQC1MQtbKqtwjeYQlvZl7sDfSk3CUXmiv7zEceVAZMHDMMGJOlCMb9zHJP-Jlp63byEV3J-CGfZ74dfqDbggOOECkkTcCaI-MHAADjCD5YnSFrThC_0Qb4Ibses9_HbwRMHFR-hs3us53_suiYaH9hXccMrD4Bv1Nmx-gDMLHPfvPwrebLylIfYW36aP5PmL-NUBxznGLyaJg8lR_wBP0DfGXK3xdizWmzAlIK7k726PuXaTF--P0Gl4QxgolAkyKgLAgTIfoZ4Z9kwo_8qj4F0D4SzH5AWwK8rgJ1TDQEFMxddXpSEcEQDP7dwfcUCW5IJUAxdPXQ1q0qsKsaKRsuqlYUU1f1KKTueS3rsaqacd9WI3_e7VvRt_tGPxemE1xIvhe8kryuqvJZ1rVuVdPzZtc2bcV2HGdlbGntdS59uBQmxoRdJXdS7gqrerRx3UMhPrWLIWbVyVMRuhz21KdLZDtuTaT4RUSG7LrCf76-vfzN5InJ42_5hrdth7JUAw5J35fBB53V-fOigPYDXtAVKdhuIloiqw9MnJk4XwxNqS-1n5k456Tb9bQE_x01MXFeW4lMnLdurp34LwAA__-vc1p1">