<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJztV0tv2zgQ_jXyhbAgUXYcHXyInWQ3QIsUu2m7N4OSKJstJQokZTv_fj9Sluy4qZGi28Ue1pAlPoYzw3l8HGaqeJ5_NKJek3fvPr0ncRJGYRzQJWF1QeyGk1JJqXaO4OGPILkJotsg6t9X0eHpusmCvFdFK_nDLQkS_OnM2Oc9Ph2BUa3O-aoUktes4gca2tHQjsYyveaWFMwyyZ5Va3sqPq4gXo3F1QTfq8lYxPQaLbzHdUK7sT_d2Bkrq0UjB2FMV6BjDYbGBdPYGI1CbHpYdXjT6dNz062yvjFboLNMyJ6IOEjugtntKX3BS1FzslWiIMEk2mlh-ScmWx44hTyvgN5Agek2oOlh5WzRNQgxVmlOBqFnslxHxNiIY7fEGCmZNH3bD3cKYeBc2ImOhGiYw6nYy7993Y_-_XnDa6LbGkGgVbveEClz0mj4N-eGFKIsuea1JXBR03YOI6L2IdMwY3hBej0K3vC6cBGkaqIaKyphmBXoSL7lMiSfhd2Q8fgxIjtOnMuMqrjduBWG10Zkkl-OPGjENIfdl75hxu9ZvlDq6_iDVkQ5Q3jtWSglgZg3L8qZxSLTS05Dw3OnOJqr1dPdX0-w-Gpl-d6iofm6lUyj1bSar0Rt4BlPfsIga4UsVluujdt_xXJlnNdin3LRkW4tVSadmGMkkdd-LufGY7Lga9i-bGsvj5yE38CxoUyKtVP9EOgnrGHdV7mfCHkZ1APXvBQrg0SziIz8CAMwXpYhqY5eSyuFYEx3112QJtNhAmbKjjPTxT4KpkNupQjZl9IQSkdZl7R-xUx3wLTeSB2D0LTZwalmtRVsZZ6rTEnz5hC5kEFPG2EQwNb4pNh6H1pFpm6fu43IN0R0U7nSGjogPU0rAXj0mhnCkEb5V6RRppQkW8wrxFYankr4Xe2QQS7kiA8slzE7n0yPdMjVfzJ16FsNfm7__zPu3884VugGn71PrNUKRq6U5cUS5rFg_uHmt7uBVhZnSXhh0eP9_WmGolBwK1Mf1n16R_vJQNBm5d5RxNELknj4nnG6PuN0JMhKcSTo2L3KCPl0xmiX_jfw5rshnXsDvxI7yRtEwTFnnuri7WzwJDbC7NkiqNL4DdxPPdCvi960Lvp5eQYo6BeeYtivRO3PPTJXriTLVdVIAVTiRYeyloiSoC71pZGwvgazR5SvOJY9O5iPXyD1Aa9RMrmiGOBuROWqUsuNdUi91qzywoR0IM7WzKGZZ2l3ihzgyxBVYgzKHaouHBWGbXFIQCALH6PQ-LodTQoQpSlqr8q5XqPeAlvH7rxyu3w8fOH1V2gCYxquocUJTFdQMcybpi-YE1Hnsi24r1YVZHJWubr0lenDaTZM-jcwneva1ehL_LtS-gSLsdWuuqY3Weu24OroZHHKQdSdVr7m_rbIJsQRbM8WufGXYgJ6tf2WuaMztnDmSm7y7mKyxEO2fWOYBWTI4-q-yv6eKSWDZ8b5wX8uAfxQQBd4yNhzvc27bhwPZu_o1UXeYUDvWeh0_YFfx3H6ZqXpDypNf53S8UXGF5L-gWRcCtRSXXYJl0bEXxWRlIW7lNTI_XUPAchcZo51G66yAAWBzK5Iofy1ZbjAFKy0L5CgA6VRMU-KNEnZiLV2o_S8A61y1Go531jb-LKN3uNZo6BrsxDggI6U2_4zBmx8gXh0hTEtCj16P03o5Gq0mRcZzVNK41l0nc_SGWOUlVnK42I2YTPOZiPJsGEzx_GHw2_08yLFnEaURnE8i6cJ3mFZRpOC80mZXfM0mV7BGRxRIEPHJ1R6PdJzzxJmdZ6SwlhznMQNEscf572GVljJ5w91b_LeK1x3N8lS6YO_fP2La3GHMWbkFZ17Lf8G-__Eug>53246</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Incorrect code generation for arm64 with i1 vectors
        </td>
    </tr>

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

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

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

<pre>
    Using LLVM 13.0.1, and the following IR:

```
; ModuleID = 'styx'
source_filename = "styx"
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-darwin20.3.0"

%Type = type { <3 x i1>}

define void @writeValue(%Type* %v)
{
  store %Type { <3 x i1> <i1 true, i1 false, i1 true>}, %Type* %v

  ret void
}
```

When run through llc produces different output data in the passed Type* depending on optimisation level. With --O0 we get something sensible:

```
cesare@Cesares-MacBook-Pro o % llc a.ll -O0
cesare@Cesares-MacBook-Pro o % cat a.s
        .section        __TEXT,__text,regular,pure_instructions
        .build_version macos, 11, 0
        .globl  _writeValue                     ; -- Begin function writeValue
        .p2align        2
_writeValue:                            ; @writeValue
        .cfi_startproc
; %bb.0:
        mov     w8, #5
        strb    w8, [x0]
        ret
        .cfi_endproc
                                        ; -- End function
.subsections_via_symbols
cesare@Cesares-MacBook-Pro o % 
```

This sets the value to 5, which is the correct result (as a packed bool vector).

However, building with -O2 produces:

```
cesare@Cesares-MacBook-Pro o % llc a.ll -O2                                                       
cesare@Cesares-MacBook-Pro o % cat a.s
        .section        __TEXT,__text,regular,pure_instructions
        .build_version macos, 11, 0
        .globl  _writeValue                     ; -- Begin function writeValue
        .p2align        2
_writeValue:                            ; @writeValue
        .cfi_startproc
; %bb.0:
        adrp    x8, __PromotedConst@PAGE
        ldrb    w8, [x8, __PromotedConst@PAGEOFF]
        and     w9, w8, #0x4
        ubfx    w10, w8, #1, #1
        and     w8, w8, #0x1
        bfi     w8, w10, #1, #1
        orr     w8, w8, w9
        strb    w8, [x0]
        ret
        .cfi_endproc
                                        ; -- End function
        .section        __TEXT,__const
        .p2align        3                               ; @_PromotedConst
__PromotedConst:
        .byte   1                               ; 0x1
        .byte   0                               ; 0x0
        .byte   1                               ; 0x1
        .space  1

.subsections_via_symbols
cesare@Cesares-MacBook-Pro o % 
```

Which is more complicated, but if you run it, it sets the memory to 1.


Here's a simple test program compiling against the two versions of this output (saved to a.O0.s and a.O2.s) demonstrating the different output:

```
jenkins@server o % cat main.cpp
#include <iostream>
#include <vector>

extern "C" void writeValue (void *buffer);

int main()
{
    int v;

    writeValue (&v);

    std::cout << v << std::endl;
}
jenkins@server o % clang -c a.O0.s; clang++ -std=c++11 main.cpp a.O0.o
jenkins@server o % ./a.out                                            
5
jenkins@server o % clang -c a.O2.s; clang++ -std=c++11 main.cpp a.O2.o
jenkins@server o % ./a.out                                            
1
jenkins@server o % 
```

I believe this is an arm64 code gen bug, but please correct me if i'm doing something daft.

Cesare
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV9-PozYQ_mvIixUEJsmGhzxs9ke70p321G5v-xYZMInvDEa2SXb_-342gWRze1FO7VV9aETAmPHMMDPfxzhTxeviDyPqNfnw4fNHEidhFMYBvSGsLojdcFIqKdXOCTz8FiTXQXQbRP15Fu2P7jZZko-qaCV_uCVBgj-9Mvb1BZdOwKhW53xVCslrVvG9DO1kaCdjmV5zSwpmmWSvqrW9FB9XMK_GYjbBdTYZi5jOMcJ5XCe0m_vdzZ2oslo0cjDGdAU51mBqXDCNF6NRiJceVu3PdPr02nSrrB9cLXFzk5AXIuIguQuubo_lC16KmpOtEgUJJtFOC8s_M9nywDnkdQX0Gg5MtwFN9yuvlt2AEGOV5mQwemLL3YgYL-LU3WCOlEyafuynO4cwcWrsyEdCNMLhXOzt376fR39-3vCa6LZGEWjVrjdEypw0GvnNuSGFKEuueW0JUtS0XcKIqH3JNMwYXpDej4I3vC5cBamaqMaKShhmBW4k33IZkmdhN2Q8fozIjhOXMqMqbjduheG1EZnk5ysPHjHNEfcbPzDjjyxfKvV1_EkrolwgvPcslJLAzMWLcmaxyPSW09Dw3DmO4Wr1dPfnEyK-Wln-YjHQfN1KpjFqWs1XojbIjBc_UpC1QharLdfGvX_FcmVc1mIPueggt5Yqk87MoZLIez-HufGYLPkasS_b2tsjR-U3aGwok2LtXN8X-pFqRPdd7UdG3hb1oDUvxcoAaBaVkR9oAMHLMoDqkLW0UijGdDfvijSZDg8QpuzwZLp8i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