|
| 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 |
| 6 | + |
| 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: |
| 13 | +; RV32: # %bb.0: |
| 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 |
| 25 | +; RV32-NEXT: # %bb.1: |
| 26 | +; RV32-NEXT: mv a5, zero |
| 27 | +; RV32-NEXT: .LBB0_2: |
| 28 | +; RV32-NEXT: srai a4, a4, 24 |
| 29 | +; RV32-NEXT: andi a5, a5, 255 |
| 30 | +; RV32-NEXT: bgtz a6, .LBB0_4 |
| 31 | +; RV32-NEXT: # %bb.3: |
| 32 | +; RV32-NEXT: mv a2, zero |
| 33 | +; RV32-NEXT: j .LBB0_5 |
| 34 | +; RV32-NEXT: .LBB0_4: |
| 35 | +; RV32-NEXT: srli a2, a2, 8 |
| 36 | +; RV32-NEXT: .LBB0_5: |
| 37 | +; RV32-NEXT: slli a2, a2, 8 |
| 38 | +; RV32-NEXT: or a2, a5, a2 |
| 39 | +; RV32-NEXT: bgtz a4, .LBB0_7 |
| 40 | +; RV32-NEXT: # %bb.6: |
| 41 | +; RV32-NEXT: mv a0, zero |
| 42 | +; RV32-NEXT: j .LBB0_8 |
| 43 | +; RV32-NEXT: .LBB0_7: |
| 44 | +; RV32-NEXT: srli a0, a0, 16 |
| 45 | +; RV32-NEXT: .LBB0_8: |
| 46 | +; RV32-NEXT: sb a0, 2(a1) |
| 47 | +; RV32-NEXT: sh a2, 0(a1) |
| 48 | +; RV32-NEXT: ret |
| 49 | +; |
| 50 | +; RV64-LABEL: vec3_setcc_crash: |
| 51 | +; RV64: # %bb.0: |
| 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 |
| 63 | +; RV64-NEXT: # %bb.1: |
| 64 | +; RV64-NEXT: mv a5, zero |
| 65 | +; RV64-NEXT: .LBB0_2: |
| 66 | +; RV64-NEXT: srai a4, a4, 56 |
| 67 | +; RV64-NEXT: andi a5, a5, 255 |
| 68 | +; RV64-NEXT: bgtz a6, .LBB0_4 |
| 69 | +; RV64-NEXT: # %bb.3: |
| 70 | +; RV64-NEXT: mv a2, zero |
| 71 | +; RV64-NEXT: j .LBB0_5 |
| 72 | +; RV64-NEXT: .LBB0_4: |
| 73 | +; RV64-NEXT: srli a2, a2, 8 |
| 74 | +; RV64-NEXT: .LBB0_5: |
| 75 | +; RV64-NEXT: slli a2, a2, 8 |
| 76 | +; RV64-NEXT: or a2, a5, a2 |
| 77 | +; RV64-NEXT: bgtz a4, .LBB0_7 |
| 78 | +; RV64-NEXT: # %bb.6: |
| 79 | +; RV64-NEXT: mv a0, zero |
| 80 | +; RV64-NEXT: j .LBB0_8 |
| 81 | +; RV64-NEXT: .LBB0_7: |
| 82 | +; RV64-NEXT: srli a0, a0, 16 |
| 83 | +; RV64-NEXT: .LBB0_8: |
| 84 | +; RV64-NEXT: sb a0, 2(a1) |
| 85 | +; RV64-NEXT: sh a2, 0(a1) |
| 86 | +; RV64-NEXT: ret |
| 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 |
| 91 | + ret void |
| 92 | +} |
0 commit comments