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

    <tr>
        <th>Summary</th>
        <td>
            AMDGPU backend cannot select error using thrust::sort on a 2 byte type
        </td>
    </tr>

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

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

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

<pre>
    Calling (hip)thrust::sort with uint16_t results in
```
fatal error: error in backend: Cannot select: t32: v8i16 = extract_subvector # D:1 t10, Constant:i32<0>
  t10: v16i16,ch = CopyFromReg # D:1 t0, Register:v16i16 %77
    t9: v16i16 = Register %77
  t28: i32 = Constant<0>
In function: _ZN7rocprim6detail16transform_kernelILj256ELj16EtPtS2_NS_8identityItEEEEvT2_mT3_T4_
```

This is using mainline clang (81b193f51bb488f41339b618c6757370be0688a4) (This commit is where I updated and built the compiler, it's not the culprit)

Source code
```
#include "thrust/sort.h"
#include <vector>

int main()
{
    const int NumElements = 8;
 std::vector<uint16_t> B(NumElements);
    thrust::sort(thrust::device, B.data(), B.data() + NumElements);
    return 0;
}

```

Compile command
```
clang++ \
-I/soft/compilers/rocm/rocm-5.5.0/include \
-O3 \
-x hip \
-c \
t1.cpp

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VFFvozgQ_jXOy6gR2AHMQx4Skpwq7fVW297LvUTGTIJbY5A9tNt_fzIkbW63OglhPHzzzdjfzKgQzNkhrlm2ZdluoUZqe7_ulH9p8M2486Lum_d1paw17gyMy9YMjJfU-jEQExsmNqH3BG-GWhiNozQ_EngMo6UAxrFkx5INy5PLM21PipQF9L73TGzmDzAOaqVf0DXRVinneoKAFnWMAyR4XF6lSXNgYgf4k7zSdAxj_Yqaeg-MC9gxsUmB0oTxCqreBVIu-pvoXiVM7OcUYMJEwjQ3ac54pduJtuqH94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