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

    <tr>
        <th>Summary</th>
        <td>
            Stores are increasing in vector.body that was loop-vectorized with LLVM16
        </td>
    </tr>

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

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

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

<pre>
    
In LLVM15, there was only one store in vector.body that was loop-vectorized.
However, in LLVM16, there are three stores.
(The same phenomenon occurs in LLVM17 as in LLVM16)

We believe that this change affects performance.

This started happening after applying the following commit.
> 078899cd64cd [SimplifyCFG] Allow SimplifyCFG hoisting to skip over non-matching instructions

This is related to the fact that SimplifyCFG, which is executed before loop-vectorize, no longer shares the store for each if condition in the loop.

- Input code (modified from TSVC s441 function)
[ sample.c ]
`
double a[20], b[20], c[20], d[20];
void func()
{
  for (int i = 0; i < 20; i++) {
    if (d[i] < (double)0.) {
      a[i] += b[i] * c[i];
    } else if (d[i] == (double)0.) {
      a[i] += b[i] * b[i];
    } else {
      a[i] += c[i] * c[i];
    }
 }
}
`

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVM2O2zYQfhr6MliBpv4POqztug2QnHaRokeKGplsKVIgKbvbpy9IKWsHC7QBAhg2RzPfz2jo4d6ri0HsSHkg5WnHlyCt675wv0jl7B984gPf9XZ46wg9Efr8ycDnz1-_7EvCjhAkOoQb92CNfgNrEHywDkEZuKII1mURCkHykMq0tfPTmlH_4JCtnL_ZG17RRUa10Vd3eu4QgnS4cfsNRFjzKhE8nxBmicZOaKwBK8Ti_DtPDdw_krYbOH3_jtCjVnjF1WGQyoOQ3FwQ-DiiCB5mdKN1EzcCs0fsa6z1gbuAA0g-z2iUuQAfAzrg86zfYhgkwmi1trcYCTtNKnyjyX8BWjdN24qhKsQApDy8qGnWanw7nn8l5QmeIxAeHoK0yodEbMH_pWawV3RgrHmaeBAyZpTxwS0iKGv8B8PKg0PNo-dgV3dchLX7R3F2hJtUQkYA_o1iiYgexzjb72cYS40Fbc0FHXjJHfpEvF6E0TpAHolGENYMKvqKA4klkem7l_oEn8y8BBB2QCCsmeygRoUDjM5O8Pry9Qi-KPYwLiY1eJ9neYg3YdaYCSDlaXta0fUw2KXXCJyUB0Zjmh2hfwzEYzC8B_lhxV-tGpIoYc1ds96ykLokrFEmgAKSn4CS_JCOR2DrmbBD-rTwgIP4WghroqKKE4-AGCe_hLU0-4CA1MZazQ5RrL_Hz6kT9eg9Ikh9AtQeP8qdIsHPKfb_qfg_TOJHvG_B--l--Dbg3dDlQ5u3fIfdvmqrsm6rtt7JbiiQjch7lpe8L4uK74e26euWsWKPPC92qmOU5XtKK9rQZl9ntKQUebnnrCxp3QpSUJy40pnW1ymz7rJT3i_YVU3eljvNe9Q-bU_GDN4gJQljcZm6LmKe-uXiSUG18sHfWYIKGruXtNLSjlNGOOR-_Q__0PqEmwpyW227xelOhjB7kj8TdibsfFFBLn0m7ETYOepuP0-zs3-iCISdk1tP2Dl1828AAAD__-iYy9A">