1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs \
3 ; RUN: -riscv-v-vector-bits-min=0 < %s | FileCheck %s --check-prefix=RV32
4 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs \
5 ; RUN: -riscv-v-vector-bits-min=0 < %s | FileCheck %s --check-prefix=RV64
7 ; This test would lead one of the DAGCombiner's visitVSELECT optimizations to
8 ; call getSetCCResultType, from which we'd return an invalid MVT (<3 x i1>)
9 ; upon seeing that the V extension is enabled. The invalid MVT has a null
10 ; Type*, which then segfaulted when accessed (as an EVT).
11 define void @vec3_setcc_crash(ptr %in, ptr %out) {
12 ; RV32-LABEL: vec3_setcc_crash:
14 ; RV32-NEXT: lw a0, 0(a0)
15 ; RV32-NEXT: srli a2, a0, 16
16 ; RV32-NEXT: slli a3, a0, 16
17 ; RV32-NEXT: srli a4, a3, 24
18 ; RV32-NEXT: srai a3, a3, 24
19 ; RV32-NEXT: slli a5, a0, 24
20 ; RV32-NEXT: srai a5, a5, 24
21 ; RV32-NEXT: slli a6, a0, 8
22 ; RV32-NEXT: srai a6, a6, 24
23 ; RV32-NEXT: sgtz a6, a6
24 ; RV32-NEXT: sgtz a5, a5
25 ; RV32-NEXT: sgtz a3, a3
26 ; RV32-NEXT: neg a3, a3
27 ; RV32-NEXT: and a3, a3, a4
28 ; RV32-NEXT: slli a3, a3, 8
29 ; RV32-NEXT: neg a4, a5
30 ; RV32-NEXT: and a0, a4, a0
31 ; RV32-NEXT: andi a0, a0, 255
32 ; RV32-NEXT: or a0, a0, a3
33 ; RV32-NEXT: neg a3, a6
34 ; RV32-NEXT: and a2, a3, a2
35 ; RV32-NEXT: sb a2, 2(a1)
36 ; RV32-NEXT: sh a0, 0(a1)
39 ; RV64-LABEL: vec3_setcc_crash:
41 ; RV64-NEXT: lw a0, 0(a0)
42 ; RV64-NEXT: srliw a2, a0, 16
43 ; RV64-NEXT: slli a3, a0, 48
44 ; RV64-NEXT: srli a4, a3, 56
45 ; RV64-NEXT: srai a3, a3, 56
46 ; RV64-NEXT: slli a5, a0, 56
47 ; RV64-NEXT: srai a5, a5, 56
48 ; RV64-NEXT: slli a6, a0, 40
49 ; RV64-NEXT: srai a6, a6, 56
50 ; RV64-NEXT: sgtz a6, a6
51 ; RV64-NEXT: sgtz a5, a5
52 ; RV64-NEXT: sgtz a3, a3
53 ; RV64-NEXT: negw a3, a3
54 ; RV64-NEXT: and a3, a3, a4
55 ; RV64-NEXT: slli a3, a3, 8
56 ; RV64-NEXT: negw a4, a5
57 ; RV64-NEXT: and a0, a4, a0
58 ; RV64-NEXT: andi a0, a0, 255
59 ; RV64-NEXT: or a0, a0, a3
60 ; RV64-NEXT: negw a3, a6
61 ; RV64-NEXT: and a2, a3, a2
62 ; RV64-NEXT: sb a2, 2(a1)
63 ; RV64-NEXT: sh a0, 0(a1)
65 %a = load <3 x i8>, ptr %in
66 %cmp = icmp sgt <3 x i8> %a, zeroinitializer
67 %c = select <3 x i1> %cmp, <3 x i8> %a, <3 x i8> zeroinitializer
68 store <3 x i8> %c, ptr %out