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

    <tr>
        <th>Summary</th>
        <td>
            [LoopVectorize] LLVM fails to vectorise loops related to order of calculation
        </td>
    </tr>

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

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

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

<pre>
    There are 2 tests ,which is very similar, https://gcc.godbolt.org/z/x1zdMP948
- first test **muladd**
```
subroutine muladd(a, b, c, n)
  implicit none
  real :: a(n), b(n), c(n), d
  integer :: i, n

  d = 0.0 
  do i = 1, n
     d = d + a(i) * b(i) + c(i)
  end do
  write(*,*) "d=",d

end subroutine muladd
```
- second test **muladd1**
```
subroutine muladd1(a, b, c, n)
  implicit none
  real :: a(n), b(n), c(n), d
  integer :: i, n

  d = 0.0 
  do i = 1, n
     d = a(i) * b(i) + c(i) + d
  end do
  write(*,*) "d=",d

end subroutine muladd1
```
we can find the only difference between them are the order of calculation in the kernel body
a) muladd: d + a(i) * b(i) + c(i), which is failed to do loop vectorize
b)muladd1:  a(i) * b(i) + c(i) + d, which is successful to do loop vectorize
 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVE2PozgQ_TXmUkoEBYRw4JCP5dQt7WHVd2MXwTsOjmyTTPevH9kkmWi6NdNzmMNEkbHNK9er90xx59RhJGpYuWXlPuGTH4xtzr3s-6Qz8rX5byBLwC0BgifnHTDcXQYlBlAOzmRfwamj0twy3MHg_cmxfMOwZdgehFgejOyM9ktjDwzbN4bt1-xNPv9bF2uW7lm6WUCvrPPxcGC4Ybg5TppLOc9nEFul139cuqmzZvJqJLhh1zzk78IgwjAyrGcwgDqetBLKw2hGum1a4hoC1XwDnOE6BsxH3OfiYS7vp42eDmRvsWrONtO8QiSwfA_pMoX7jgEVN7MHOITfjJXAcBt5KIZ10CESuS62kYl6KIlGCdLcVherPDFcR8l2cQxhKFm-Z4gMd_KRYAh-L-FHQi_AkTCjfO9O9jv2ZH-9P792Ji7kn_Mn-1DqC4HgI_QqeDQQmFG_glR9T5ZGQdCRvxCN4d0xfsURZCVZMD0IrsWkuVdmBBVB8IXsSBrCtz9n4IHr9Yrkm89fVNzBvU30XGmS4E3QWRtzgjMJb6x6u9rdsX9att2xdX0rNt_A50V_zOUmIci5ftI_yQeJbHJZ5zVPqMmqbFXVJWKdDE2dZWmJ6zSTUooMu6oUZcm7QmKeZSIrEtVgikVaYpVWeV7Uy_UKs6oWeV2sqlVd9axI6ciVXmp9Poa-lyjnJmrqvCjKRPOOtIv9FnGkC8SX4RKU-8Q2IWbRTQfHilQr5933U7zyOjbqJ2NOL_d6yj08Pb08R41dKPlaqqNYuQNLmvtZ_Y-MTyarmx_6tvLD1C2FOTJsQ_7rY3Gy5n8SnmEbWTuG7VzVucFvAQAA__9Al8Xg">