<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55606>55606</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] crash on compiling umaxv/vcvtfxu2fp neon intrinsics, assertion "unexpected vector type"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Benjins
</td>
</tr>
</table>
<pre>
The following IR when compiled via llc for the aarch64 backend will crash or hit in assertion if they're enabled.
[Godbolt link](https://godbolt.org/z/Ts75WMdTs)
```
; Compiled with llc --mtriple=aarch64-none-none -O0
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn uwtable
define dso_local float @do_stuff(<8 x i16> noundef %var_135) local_unnamed_addr #0 {
entry:
%vmaxv.i = call i32 @llvm.aarch64.neon.umaxv.i32.v8i16(<8 x i16> %var_135) #2
%vcvts_n_f32_u32 = call float @llvm.aarch64.neon.vcvtfxu2fp.f32.i32(i32 %vmaxv.i, i32 1)
ret float %vcvts_n_f32_u32
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
declare float @llvm.aarch64.neon.vcvtfxu2fp.f32.i32(i32, i32) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
declare i32 @llvm.aarch64.neon.umaxv.i32.v8i16(<8 x i16>) #1
```
The assertion we get is in `tryCombineFixedPointConvert`:
```
unexpected vector type!
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:15076!
```
[Full LLC crash log](https://github.com/llvm/llvm-project/files/8735112/2022_05_19_llc_crash_log.txt)
The DAG at the point of the assertion:
```
SelectionDAG has 12 nodes:
t0: ch = EntryToken
t2: v8i16,ch = CopyFromReg t0, Register:v8i16 %0
t14: v8i16 = AArch64ISD::UMAXV t2
t15: i32 = extract_vector_elt t14, Constant:i64<0>
t9: f32 = llvm.aarch64.neon.vcvtfxu2fp TargetConstant:i64<627>, t15, Constant:i32<2>
t11: ch,glue = CopyToReg t0, Register:f32 $s0, t9
t12: ch = AArch64ISD::RET_FLAG t11, Register:f32 $s0, t11:1
```
The following is a minimal repro of the error via C++ when compiled with -O1:
[Godbolt link](https://godbolt.org/z/nPMr81qo9)
```
#include <arm_neon.h>
float32_t do_stuff(uint16x8_t Input) {
uint16_t MaxElem = vmaxvq_u16(Input);
float32_t MaxAsFloat = vcvts_n_f32_u32(MaxElem, 1);
return MaxAsFloat;
}
```
I have verified that this repros on the latest trunk (6e00a34cdb49ba1d4b72ec274e52260da9c52380).
For context: this code was generated by a fuzzer, it was not manually written.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Vktz2zYQ_jXUBWMOCYqSeNBBpqzUM3aTcZ22Nw5IgiISEFDw0CO_vguI1Ctu0uTQjCKKxr73229RyvowD6JlEC1eW4oaybncMbFGjy9o11KBKtltGKc12jKCOK9ARCEDooSoqp2MUUmqz1TUaMc4R5UiukUg0TKDmEBEa6oMkwKxxmkdAjxVFFFBSrAZHh333-n9O1mXkhvEmfgcpMsAz1pjNjpIFgFewWd9PA-lWsPbV_j_qqfpX8_1qw5wdmVsEvWf42tyj_IhkR0zrc_k7q4zim04DZJln82dkIL6L3T3_kJ5ZUXl01gYo1xAqLPabJRcK6o1ErJRlMJDH0QFDyughjVSlNTelquNosYqgezOuNyPpmvaMDiutSy4rAhHDZfEoGAc1bLQxjYN1CBI8hnaIxZPguTBGwc1FOB0S1QRJymkjrx2YYUgHa0LUtcKBJIIBdP7oycqjDq4Qvo35NU7st-GDEH2CLQ5Ygl2rjnfdmFfj1BQKUJ7lExwuJ25MG5juo4FHONLN9XW6EIUTYIL6zwM7k65fuvQ6TR7i5tNCGrOM_j04Z3CDnDuA45PnUdQbzNY_cZv38vp8gom_6W1LlgH8p_o8tDdihNA-y8k2mfXlzP-_2P-VSzcRHwzhieeOfPCjqI1tI1pRxcgCTCFSS1hLFZsT-sP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