# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - \
# RUN: | FileCheck %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
tracksRegLiveness: true
jumpTable:
kind: block-address
entries:
- id: 0
blocks: [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.6', '%bb.7' ]
body: |
; CHECK-LABEL: name: jt_test
; CHECK: bb.0.entry:
; CHECK-NEXT: successors: %bb.8(0x40000000), %bb.1(0x40000000)
; CHECK-NEXT: liveins: $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 200
; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 100
; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK-NEXT: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
; CHECK-NEXT: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK-NEXT: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 4
; CHECK-NEXT: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 1000
; CHECK-NEXT: [[C8:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[COPY]], [[C8]]
; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[SUB]](s32), [[C]]
; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.8
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1.entry:
; CHECK-NEXT: successors: %bb.2(0x15555555), %bb.3(0x15555555), %bb.4(0x15555555), %bb.5(0x15555555), %bb.6(0x15555555), %bb.7(0x15555555)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[JUMP_TABLE:%[0-9]+]]:_(p0) = G_JUMP_TABLE %jump-table.0
; CHECK-NEXT: G_BRJT [[JUMP_TABLE]](p0), %jump-table.0, [[SUB]](s32)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2.bb1:
; CHECK-NEXT: $x10 = COPY [[C6]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.3.bb2:
; CHECK-NEXT: $x10 = COPY [[C5]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.4.bb3:
; CHECK-NEXT: $x10 = COPY [[C4]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.5.bb4:
; CHECK-NEXT: $x10 = COPY [[C3]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.6.bb5:
; CHECK-NEXT: $x10 = COPY [[C2]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.7.bb6:
; CHECK-NEXT: $x10 = COPY [[C1]](s32)
; CHECK-NEXT: PseudoRET implicit $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.8.default:
; CHECK-NEXT: $x10 = COPY [[C7]](s32)
; CHECK-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
%6:_(s1) = G_ICMP intpred(ugt), %2(s32), %4
G_BRCOND %6(s1), %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
...