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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] Performance is now affected due to unaligned access
        </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>
    * test, https://godbolt.org/z/xenn3Kccq
```
#define NUM 8092

__attribute__((noinline)) int callee (int a[], int n) {
 for (int i=0; i<n; i++)
       a[i] = i * 50;
}

int foo_unalign (int num) {
    
    int array[NUM];

    callee (array, NUM);

    return 0;
}


int foo_align64 (int num) {
 
    __attribute__ ((aligned (64))) int array[NUM];

    callee (array, NUM);

    return 0;
}
```
consider that, the array will not aligned to 64 bytes in function **foo_unalign**, so there will be unaligned access in the loop kernel of callee, and the performance will be inefficient compare to **foo_align64**.

In order to get better performance , we should check the address of  a[0] in  function **callee**, and try the loop peel to guard that the address in loop kernel will be aligned ?


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VMGu6jYQ_RpnM3oo2EkgiyzgokhV9Z66eWvk2GPiPmNT27mUfn1lJ1zgVndbZIFtxmfOmTMaHoI-WcSO1HtSHwo-xdH57l1JpYrByVtH6A4ihkjoG4wxXgJhO0J7QvuTk4MzceX8idD-H0L7v9Fa9rsQf5HyQModacplzUfKJCptEX78_A7bsqXLff4-HnmMXg9TxOOR0C2hW-u0NdoioS2hLWgbQXBjEIHQbTrxmXWilo42RZHNfgYE5fw9UBN2KAnbp82bnTd0n1e7RM-fhKhJfQDCDqAhia_Tw4Xp5vBMOSEr546T5Uaf7D2Znc6vRADgscu8vec3Uu9__Pye6H_AfwQ9ZM6h9C3VLJH9b6zHOHkLX7J85ZqZNtWXXB-4L4bA7Eh-jTKdmmq25e7M_6XptaeEs0FL9BBHnls0jjhTgas2BqyLcCcdHTQVDLeIAbQFNVkRtUu27QjdPRk5XyS04BKgxxlsQFgiUAIXAkMGSimNcxf4hd6iAacWrQmBW5kDLuiV82duxQNMW1RKC42psd35wj0mkg8-i1nzxeq5SL9ZcD7rdnDCCAPGiP4lS8p-RQijm4wEMaL4NVdHSp-YOzW3e5naXVv4XJC7hnstshJ_e8i9IJqcf-JeZgNe8LV9qcpd9EcLsf5ZUCE7JlvW8gK7dbNhbN1WzaYYu7quhrpd17JiiBWv1rSWA1eM822r1GYodEdLysr1uixpvamaVTmULW23HBVrmEBOqhLPXJuVMe_nNK0KHcKEXd22a1oYPqAJef5RavEK-U9CaRqHvktvvg3TKZCqNDrE8ECJOpo8OHc7L8amSnX848kAHcC6K3ClUESUIKds7-cWKiZvuk-TVcdxGlbCnQntU77l59vFuz9RREL7zDIQ2mcV_wYAAP__9u-35w">