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

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

--- |
  define i32 @jt_test(i32 signext %in) {
  entry:
    %0 = sext i32 %in to i64
    switch i64 %0, label %default [
      i64 1, label %bb1
      i64 2, label %bb2
      i64 3, label %bb3
      i64 4, label %bb4
      i64 5, label %bb5
      i64 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:            custom32
  entries:
    - id:              0
      blocks:          [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.6', '%bb.7' ]
body:             |
  ; RV64I-LABEL: name: jt_test
  ; RV64I: bb.0.entry:
  ; RV64I-NEXT:   liveins: $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT:   [[COPY:%[0-9]+]]:gprb(s64) = COPY $x10
  ; RV64I-NEXT:   [[ASSERT_SEXT:%[0-9]+]]:gprb(s64) = G_ASSERT_SEXT [[COPY]], 32
  ; RV64I-NEXT:   [[C:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 5
  ; RV64I-NEXT:   [[SEXT_INREG:%[0-9]+]]:gprb(s64) = G_SEXT_INREG [[ASSERT_SEXT]], 32
  ; RV64I-NEXT:   [[C1:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 1
  ; RV64I-NEXT:   [[SUB:%[0-9]+]]:gprb(s64) = G_SUB [[SEXT_INREG]], [[C1]]
  ; RV64I-NEXT:   [[ICMP:%[0-9]+]]:gprb(s64) = G_ICMP intpred(ugt), [[SUB]](s64), [[C]]
  ; RV64I-NEXT:   G_BRCOND [[ICMP]](s64), %bb.8
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.1.entry:
  ; RV64I-NEXT:   successors: %bb.2, %bb.3, %bb.4, %bb.5, %bb.6, %bb.7
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT:   [[JUMP_TABLE:%[0-9]+]]:gprb(p0) = G_JUMP_TABLE %jump-table.0
  ; RV64I-NEXT:   G_BRJT [[JUMP_TABLE]](p0), %jump-table.0, [[SUB]](s64)
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.2.bb1:
  ; RV64I-NEXT:   [[C2:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 4
  ; RV64I-NEXT:   $x10 = COPY [[C2]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.3.bb2:
  ; RV64I-NEXT:   [[C3:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 3
  ; RV64I-NEXT:   $x10 = COPY [[C3]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.4.bb3:
  ; RV64I-NEXT:   [[C4:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 2
  ; RV64I-NEXT:   $x10 = COPY [[C4]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.5.bb4:
  ; RV64I-NEXT:   [[C5:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 1
  ; RV64I-NEXT:   $x10 = COPY [[C5]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.6.bb5:
  ; RV64I-NEXT:   [[C6:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 100
  ; RV64I-NEXT:   $x10 = COPY [[C6]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.7.bb6:
  ; RV64I-NEXT:   [[C7:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 200
  ; RV64I-NEXT:   $x10 = COPY [[C7]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  ; RV64I-NEXT: {{  $}}
  ; RV64I-NEXT: bb.8.default:
  ; RV64I-NEXT:   [[C8:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 1000
  ; RV64I-NEXT:   $x10 = COPY [[C8]](s64)
  ; RV64I-NEXT:   PseudoRET implicit $x10
  bb.1.entry:
    successors: %bb.8, %bb.9
    liveins: $x10

    %1:_(s64) = COPY $x10
    %2:_(s64) = G_ASSERT_SEXT %1, 32
    %7:_(s64) = G_CONSTANT i64 5
    %3:_(s64) = G_SEXT_INREG %2, 32
    %4:_(s64) = G_CONSTANT i64 1
    %5:_(s64) = G_SUB %3, %4
    %26:_(s64) = G_ICMP intpred(ugt), %5(s64), %7
    G_BRCOND %26(s64), %bb.8

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

    %10:_(p0) = G_JUMP_TABLE %jump-table.0
    G_BRJT %10(p0), %jump-table.0, %5(s64)

  bb.2.bb1:
    %22:_(s64) = G_CONSTANT i64 4
    $x10 = COPY %22(s64)
    PseudoRET implicit $x10

  bb.3.bb2:
    %20:_(s64) = G_CONSTANT i64 3
    $x10 = COPY %20(s64)
    PseudoRET implicit $x10

  bb.4.bb3:
    %18:_(s64) = G_CONSTANT i64 2
    $x10 = COPY %18(s64)
    PseudoRET implicit $x10

  bb.5.bb4:
    %16:_(s64) = G_CONSTANT i64 1
    $x10 = COPY %16(s64)
    PseudoRET implicit $x10

  bb.6.bb5:
    %14:_(s64) = G_CONSTANT i64 100
    $x10 = COPY %14(s64)
    PseudoRET implicit $x10

  bb.7.bb6:
    %12:_(s64) = G_CONSTANT i64 200
    $x10 = COPY %12(s64)
    PseudoRET implicit $x10

  bb.8.default:
    %24:_(s64) = G_CONSTANT i64 1000
    $x10 = COPY %24(s64)
    PseudoRET implicit $x10

...