1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefix=RV32
4 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s \
5 ; RUN: | 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(<3 x i8>* %in, <3 x i8>* %out) {
12 ; RV32-LABEL: vec3_setcc_crash:
14 ; RV32-NEXT: lw a0, 0(a0)
15 ; RV32-NEXT: lui a2, 16
16 ; RV32-NEXT: addi a2, a2, -256
17 ; RV32-NEXT: and a2, a0, a2
18 ; RV32-NEXT: slli a3, a2, 16
19 ; RV32-NEXT: srai a6, a3, 24
20 ; RV32-NEXT: slli a4, a0, 24
21 ; RV32-NEXT: srai a3, a4, 24
22 ; RV32-NEXT: slli a4, a0, 8
23 ; RV32-NEXT: mv a5, a0
24 ; RV32-NEXT: bgtz a3, .LBB0_2
26 ; RV32-NEXT: mv a5, zero
28 ; RV32-NEXT: srai a4, a4, 24
29 ; RV32-NEXT: andi a5, a5, 255
30 ; RV32-NEXT: bgtz a6, .LBB0_4
32 ; RV32-NEXT: mv a2, zero
33 ; RV32-NEXT: j .LBB0_5
35 ; RV32-NEXT: srli a2, a2, 8
37 ; RV32-NEXT: slli a2, a2, 8
38 ; RV32-NEXT: or a2, a5, a2
39 ; RV32-NEXT: bgtz a4, .LBB0_7
41 ; RV32-NEXT: mv a0, zero
42 ; RV32-NEXT: j .LBB0_8
44 ; RV32-NEXT: srli a0, a0, 16
46 ; RV32-NEXT: sb a0, 2(a1)
47 ; RV32-NEXT: sh a2, 0(a1)
50 ; RV64-LABEL: vec3_setcc_crash:
52 ; RV64-NEXT: lwu a0, 0(a0)
53 ; RV64-NEXT: lui a2, 16
54 ; RV64-NEXT: addiw a2, a2, -256
55 ; RV64-NEXT: and a2, a0, a2
56 ; RV64-NEXT: slli a3, a2, 48
57 ; RV64-NEXT: srai a6, a3, 56
58 ; RV64-NEXT: slli a4, a0, 56
59 ; RV64-NEXT: srai a3, a4, 56
60 ; RV64-NEXT: slli a4, a0, 40
61 ; RV64-NEXT: mv a5, a0
62 ; RV64-NEXT: bgtz a3, .LBB0_2
64 ; RV64-NEXT: mv a5, zero
66 ; RV64-NEXT: srai a4, a4, 56
67 ; RV64-NEXT: andi a5, a5, 255
68 ; RV64-NEXT: bgtz a6, .LBB0_4
70 ; RV64-NEXT: mv a2, zero
71 ; RV64-NEXT: j .LBB0_5
73 ; RV64-NEXT: srli a2, a2, 8
75 ; RV64-NEXT: slli a2, a2, 8
76 ; RV64-NEXT: or a2, a5, a2
77 ; RV64-NEXT: bgtz a4, .LBB0_7
79 ; RV64-NEXT: mv a0, zero
80 ; RV64-NEXT: j .LBB0_8
82 ; RV64-NEXT: srli a0, a0, 16
84 ; RV64-NEXT: sb a0, 2(a1)
85 ; RV64-NEXT: sh a2, 0(a1)
87 %a = load <3 x i8>, <3 x i8>* %in
88 %cmp = icmp sgt <3 x i8> %a, zeroinitializer
89 %c = select <3 x i1> %cmp, <3 x i8> %a, <3 x i8> zeroinitializer
90 store <3 x i8> %c, <3 x i8>* %out