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

    <tr>
        <th>Summary</th>
        <td>
            Incorrect semantics of bitwise shifts of vector types
        </td>
    </tr>

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

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

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

<pre>
    Consider
```c
typedef short v8hi __attribute__((vector_size(16)));

void f(v8hi *x)
{
 *x <<= 16;
}

typedef short i16v8 __attribute__((ext_vector_type(8)));

void g(i16v8 *x)
{
    *x <<= 16;
}
```
https://godbolt.org/z/Gr56v61fc

Both functions are compiled down to no-op, as if implied element-wise integer promotion before shift does not happen and the attempted shift by 16 bits is UB. For `ext_vector_type` LLVM needs to define and document the semantics, but for `vector_size` it should be compatible with GCC, where such shifts work as if each element is shifted with C semantics.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk0-PpDYQxT-NuZSmBeZP0wcOM91iFWlzTK4tYxeNs-BCdtG9s58-MjDqySqJViqBjF49__zKqBDszSE2onwT5SVRCw_kGzWRU9_onnRk3pszuWANepFeRPoqqnQrva35fUaDPYSBPMO9Hixcr4rZ225hvF6FrIWs76iZ_DXYHyhknVVCnvbK33bf9Xkna6CPDdFIyNfvUbMJjrty_QwiP691gax6mhwvn93-yWaz6l7_Gxx-5-sOGDuErOv_5bsJWW9m_wEI8EuMH0luy4F5DiJ_FbIVsr2R6WjkA_mbkO0PIdsvvqzuVdbrzzxvxAP0i9NsyQVQHkHTNNsRDRh6OGACRy80C3kGFcD2YKd5tGgAR5zQ8cvDBgTrGG_oYfY0UfSCDnvyCGGwPYMhDOCIYVDzjA6UM8ADgmLGaWY0u657h6yCznIAG-CPtwO05EFU6c8RVyl8_frn7-AQTYiQBnvrcDU2pJdItu4QcFKOrQ7xAN3C0G-Gny9UlYLlOORlNNBtCSi23YjwsDzAl_M5dj8GjAda9LDRBniQ_7angkoPH5FE9lWBZjM4PzEOiWlyc8pPKsEmq-rilNVlUSdDg0eZdbIyWWHqItdll_Unhb05yiP2-iQT28hU5mkpi7Quy6I-qPKoC6ULk_dlKdNcFClOyo6HcbxPcfKJDWHBppKnLE1G1eEYPv5U30TRS7fcgijS0QYOzza2PGLzm9PkPWp-0gP1cTrryPcMqIctS4iDCcnix-anq2h5WLqDpknINu6xv15mT3-hZiHblTMI2a6ofwcAAP__s6lcuw">