File: vec3-setcc-crash.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (70 lines) | stat: -rw-r--r-- 2,425 bytes parent folder | download | duplicates (5)
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
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs \
; RUN:     -riscv-v-vector-bits-min=0 < %s | FileCheck %s --check-prefix=RV32
; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs \
; RUN:     -riscv-v-vector-bits-min=0 < %s | 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(ptr %in, ptr %out) {
; RV32-LABEL: vec3_setcc_crash:
; RV32:       # %bb.0:
; RV32-NEXT:    lw a0, 0(a0)
; RV32-NEXT:    srli a2, a0, 16
; RV32-NEXT:    srli a3, a0, 8
; RV32-NEXT:    slli a4, a0, 16
; RV32-NEXT:    srai a4, a4, 24
; RV32-NEXT:    slli a5, a0, 24
; RV32-NEXT:    srai a5, a5, 24
; RV32-NEXT:    slli a6, a0, 8
; RV32-NEXT:    srai a6, a6, 24
; RV32-NEXT:    sgtz a6, a6
; RV32-NEXT:    sgtz a5, a5
; RV32-NEXT:    sgtz a4, a4
; RV32-NEXT:    neg a4, a4
; RV32-NEXT:    and a3, a4, a3
; RV32-NEXT:    slli a3, a3, 8
; RV32-NEXT:    neg a4, a5
; RV32-NEXT:    and a0, a4, a0
; RV32-NEXT:    andi a0, a0, 255
; RV32-NEXT:    or a0, a0, a3
; RV32-NEXT:    neg a3, a6
; RV32-NEXT:    and a2, a3, a2
; RV32-NEXT:    sb a2, 2(a1)
; RV32-NEXT:    sh a0, 0(a1)
; RV32-NEXT:    ret
;
; RV64-LABEL: vec3_setcc_crash:
; RV64:       # %bb.0:
; RV64-NEXT:    lw a0, 0(a0)
; RV64-NEXT:    srli a2, a0, 16
; RV64-NEXT:    srli a3, a0, 8
; RV64-NEXT:    slli a4, a0, 48
; RV64-NEXT:    srai a4, a4, 56
; RV64-NEXT:    slli a5, a0, 56
; RV64-NEXT:    srai a5, a5, 56
; RV64-NEXT:    slli a6, a0, 40
; RV64-NEXT:    srai a6, a6, 56
; RV64-NEXT:    sgtz a6, a6
; RV64-NEXT:    sgtz a5, a5
; RV64-NEXT:    sgtz a4, a4
; RV64-NEXT:    negw a4, a4
; RV64-NEXT:    and a3, a4, a3
; RV64-NEXT:    slli a3, a3, 8
; RV64-NEXT:    negw a4, a5
; RV64-NEXT:    and a0, a4, a0
; RV64-NEXT:    andi a0, a0, 255
; RV64-NEXT:    or a0, a0, a3
; RV64-NEXT:    negw a3, a6
; RV64-NEXT:    and a2, a3, a2
; RV64-NEXT:    sb a2, 2(a1)
; RV64-NEXT:    sh a0, 0(a1)
; RV64-NEXT:    ret
  %a = load <3 x i8>, ptr %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, ptr %out
  ret void
}