llvm/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/jump-table-brjt-rv32.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv32 -run-pass=regbankselect \
# RUN:   -simplify-mir -verify-machineinstrs %s \
# RUN:   -o - | FileCheck -check-prefix=RV32I %s

--- |
  define i32 @jt_test(i32 signext %in) {
  entry:
    switch i32 %in, label %default [
      i32 1, label %bb1
      i32 2, label %bb2
      i32 3, label %bb3
      i32 4, label %bb4
      i32 5, label %bb5
      i32 6, label %bb6
    ]

  bb1:                                              ; preds = %entry
    ret i32 4

  bb2:                                              ; preds = %entry
    ret i32 3

  bb3:                                              ; preds = %entry
    ret i32 2

  bb4:                                              ; preds = %entry
    ret i32 1

  bb5:                                              ; preds = %entry
    ret i32 100

  bb6:                                              ; preds = %entry
    ret i32 200

  default:                                          ; preds = %entry
    ret i32 1000
  }

...
---
name:            jt_test
legalized:       true
tracksRegLiveness: true
jumpTable:
  kind:            block-address
  entries:
    - id:              0
      blocks:          [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.6', '%bb.7' ]
body:             |
  ; RV32I-LABEL: name: jt_test
  ; RV32I: bb.0.entry:
  ; RV32I-NEXT:   liveins: $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT:   [[COPY:%[0-9]+]]:gprb(s32) = COPY $x10
  ; RV32I-NEXT:   [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 5
  ; RV32I-NEXT:   [[C1:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 200
  ; RV32I-NEXT:   [[C2:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 100
  ; RV32I-NEXT:   [[C3:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1
  ; RV32I-NEXT:   [[C4:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 2
  ; RV32I-NEXT:   [[C5:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 3
  ; RV32I-NEXT:   [[C6:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 4
  ; RV32I-NEXT:   [[C7:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1000
  ; RV32I-NEXT:   [[C8:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 1
  ; RV32I-NEXT:   [[SUB:%[0-9]+]]:gprb(s32) = G_SUB [[COPY]], [[C8]]
  ; RV32I-NEXT:   [[ICMP:%[0-9]+]]:gprb(s32) = G_ICMP intpred(ugt), [[SUB]](s32), [[C]]
  ; RV32I-NEXT:   G_BRCOND [[ICMP]](s32), %bb.8
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.1.entry:
  ; RV32I-NEXT:   successors: %bb.2, %bb.3, %bb.4, %bb.5, %bb.6, %bb.7
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT:   [[JUMP_TABLE:%[0-9]+]]:gprb(p0) = G_JUMP_TABLE %jump-table.0
  ; RV32I-NEXT:   G_BRJT [[JUMP_TABLE]](p0), %jump-table.0, [[SUB]](s32)
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.2.bb1:
  ; RV32I-NEXT:   $x10 = COPY [[C6]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.3.bb2:
  ; RV32I-NEXT:   $x10 = COPY [[C5]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.4.bb3:
  ; RV32I-NEXT:   $x10 = COPY [[C4]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.5.bb4:
  ; RV32I-NEXT:   $x10 = COPY [[C3]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.6.bb5:
  ; RV32I-NEXT:   $x10 = COPY [[C2]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.7.bb6:
  ; RV32I-NEXT:   $x10 = COPY [[C1]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  ; RV32I-NEXT: {{  $}}
  ; RV32I-NEXT: bb.8.default:
  ; RV32I-NEXT:   $x10 = COPY [[C7]](s32)
  ; RV32I-NEXT:   PseudoRET implicit $x10
  bb.1.entry:
    successors: %bb.8, %bb.9
    liveins: $x10

    %0:_(s32) = COPY $x10
    %4:_(s32) = G_CONSTANT i32 5
    %8:_(s32) = G_CONSTANT i32 200
    %9:_(s32) = G_CONSTANT i32 100
    %10:_(s32) = G_CONSTANT i32 1
    %11:_(s32) = G_CONSTANT i32 2
    %12:_(s32) = G_CONSTANT i32 3
    %13:_(s32) = G_CONSTANT i32 4
    %14:_(s32) = G_CONSTANT i32 1000
    %1:_(s32) = G_CONSTANT i32 1
    %2:_(s32) = G_SUB %0, %1
    %16:_(s32) = G_ICMP intpred(ugt), %2(s32), %4
    G_BRCOND %16(s32), %bb.8

  bb.9.entry:
    successors: %bb.2, %bb.3, %bb.4, %bb.5, %bb.6, %bb.7

    %7:_(p0) = G_JUMP_TABLE %jump-table.0
    G_BRJT %7(p0), %jump-table.0, %2(s32)

  bb.2.bb1:
    $x10 = COPY %13(s32)
    PseudoRET implicit $x10

  bb.3.bb2:
    $x10 = COPY %12(s32)
    PseudoRET implicit $x10

  bb.4.bb3:
    $x10 = COPY %11(s32)
    PseudoRET implicit $x10

  bb.5.bb4:
    $x10 = COPY %10(s32)
    PseudoRET implicit $x10

  bb.6.bb5:
    $x10 = COPY %9(s32)
    PseudoRET implicit $x10

  bb.7.bb6:
    $x10 = COPY %8(s32)
    PseudoRET implicit $x10

  bb.8.default:
    $x10 = COPY %14(s32)
    PseudoRET implicit $x10

...