File: vec3-setcc-crash.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (92 lines) | stat: -rw-r--r-- 2,934 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s \
; RUN:     | FileCheck %s --check-prefix=RV32
; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s \
; RUN:     | FileCheck %s --check-prefix=RV64

; This test would lead one of the DAGCombiner's visitVSELECT optimizations to
; call getSetCCResultType, from which we'd return an invalid MVT (<3 x i1>)
; upon seeing that the V extension is enabled. The invalid MVT has a null
; Type*, which then segfaulted when accessed (as an EVT).
define void @vec3_setcc_crash(<3 x i8>* %in, <3 x i8>* %out) {
; RV32-LABEL: vec3_setcc_crash:
; RV32:       # %bb.0:
; RV32-NEXT:    lw a0, 0(a0)
; RV32-NEXT:    lui a2, 16
; RV32-NEXT:    addi a2, a2, -256
; RV32-NEXT:    and a2, a0, a2
; RV32-NEXT:    slli a3, a2, 16
; RV32-NEXT:    srai a3, a3, 24
; RV32-NEXT:    slli a4, a0, 24
; RV32-NEXT:    srai a6, a4, 24
; RV32-NEXT:    slli a4, a0, 8
; RV32-NEXT:    mv a5, a0
; RV32-NEXT:    bgtz a6, .LBB0_2
; RV32-NEXT:  # %bb.1:
; RV32-NEXT:    li a5, 0
; RV32-NEXT:  .LBB0_2:
; RV32-NEXT:    srai a4, a4, 24
; RV32-NEXT:    andi a5, a5, 255
; RV32-NEXT:    bgtz a3, .LBB0_4
; RV32-NEXT:  # %bb.3:
; RV32-NEXT:    li a2, 0
; RV32-NEXT:    j .LBB0_5
; RV32-NEXT:  .LBB0_4:
; RV32-NEXT:    srli a2, a2, 8
; RV32-NEXT:  .LBB0_5:
; RV32-NEXT:    slli a2, a2, 8
; RV32-NEXT:    or a2, a5, a2
; RV32-NEXT:    bgtz a4, .LBB0_7
; RV32-NEXT:  # %bb.6:
; RV32-NEXT:    li a0, 0
; RV32-NEXT:    j .LBB0_8
; RV32-NEXT:  .LBB0_7:
; RV32-NEXT:    srli a0, a0, 16
; RV32-NEXT:  .LBB0_8:
; RV32-NEXT:    sb a0, 2(a1)
; RV32-NEXT:    sh a2, 0(a1)
; RV32-NEXT:    ret
;
; RV64-LABEL: vec3_setcc_crash:
; RV64:       # %bb.0:
; RV64-NEXT:    lwu a0, 0(a0)
; RV64-NEXT:    lui a2, 16
; RV64-NEXT:    addiw a2, a2, -256
; RV64-NEXT:    and a2, a0, a2
; RV64-NEXT:    slli a3, a2, 48
; RV64-NEXT:    srai a3, a3, 56
; RV64-NEXT:    slli a4, a0, 56
; RV64-NEXT:    srai a6, a4, 56
; RV64-NEXT:    slli a4, a0, 40
; RV64-NEXT:    mv a5, a0
; RV64-NEXT:    bgtz a6, .LBB0_2
; RV64-NEXT:  # %bb.1:
; RV64-NEXT:    li a5, 0
; RV64-NEXT:  .LBB0_2:
; RV64-NEXT:    srai a4, a4, 56
; RV64-NEXT:    andi a5, a5, 255
; RV64-NEXT:    bgtz a3, .LBB0_4
; RV64-NEXT:  # %bb.3:
; RV64-NEXT:    li a2, 0
; RV64-NEXT:    j .LBB0_5
; RV64-NEXT:  .LBB0_4:
; RV64-NEXT:    srli a2, a2, 8
; RV64-NEXT:  .LBB0_5:
; RV64-NEXT:    slli a2, a2, 8
; RV64-NEXT:    or a2, a5, a2
; RV64-NEXT:    bgtz a4, .LBB0_7
; RV64-NEXT:  # %bb.6:
; RV64-NEXT:    li a0, 0
; RV64-NEXT:    j .LBB0_8
; RV64-NEXT:  .LBB0_7:
; RV64-NEXT:    srli a0, a0, 16
; RV64-NEXT:  .LBB0_8:
; RV64-NEXT:    sb a0, 2(a1)
; RV64-NEXT:    sh a2, 0(a1)
; RV64-NEXT:    ret
  %a = load <3 x i8>, <3 x i8>* %in
  %cmp = icmp sgt <3 x i8> %a, zeroinitializer
  %c = select <3 x i1> %cmp, <3 x i8> %a, <3 x i8> zeroinitializer
  store <3 x i8> %c, <3 x i8>* %out
  ret void
}