1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv64 -run-pass=instruction-select %s -o - \
3 # RUN: -code-model=small | FileCheck %s
6 define i32 @jt_test(i32 signext %in) {
8 %0 = sext i32 %in to i64
9 switch i64 %0, label %default [
36 default: ; preds = %entry
45 tracksRegLiveness: true
50 blocks: [ '%bb.2', '%bb.3', '%bb.4', '%bb.5', '%bb.6', '%bb.7' ]
52 ; CHECK-LABEL: name: jt_test
54 ; CHECK-NEXT: successors: %bb.8(0x40000000), %bb.1(0x40000000)
55 ; CHECK-NEXT: liveins: $x10
57 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
58 ; CHECK-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI $x0, 5
59 ; CHECK-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[COPY]], 0
60 ; CHECK-NEXT: [[ADDI1:%[0-9]+]]:gpr = ADDI [[ADDIW]], -1
61 ; CHECK-NEXT: BLTU [[ADDI]], [[ADDI1]], %bb.8
63 ; CHECK-NEXT: bb.1.entry:
64 ; CHECK-NEXT: successors: %bb.2(0x15555555), %bb.3(0x15555555), %bb.4(0x15555555), %bb.5(0x15555555), %bb.6(0x15555555), %bb.7(0x15555555)
66 ; CHECK-NEXT: [[LUI:%[0-9]+]]:gpr = LUI target-flags(riscv-hi) %jump-table.0
67 ; CHECK-NEXT: [[ADDI2:%[0-9]+]]:gpr = ADDI [[LUI]], target-flags(riscv-lo) %jump-table.0
68 ; CHECK-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[ADDI1]], 2
69 ; CHECK-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[ADDI2]], [[SLLI]]
70 ; CHECK-NEXT: [[LW:%[0-9]+]]:gprjalr = LW [[ADD]], 0 :: (load (s32) from jump-table)
71 ; CHECK-NEXT: PseudoBRIND [[LW]], 0
73 ; CHECK-NEXT: bb.2.bb1:
74 ; CHECK-NEXT: [[ADDI3:%[0-9]+]]:gpr = ADDI $x0, 4
75 ; CHECK-NEXT: $x10 = COPY [[ADDI3]]
76 ; CHECK-NEXT: PseudoRET implicit $x10
78 ; CHECK-NEXT: bb.3.bb2:
79 ; CHECK-NEXT: [[ADDI4:%[0-9]+]]:gpr = ADDI $x0, 3
80 ; CHECK-NEXT: $x10 = COPY [[ADDI4]]
81 ; CHECK-NEXT: PseudoRET implicit $x10
83 ; CHECK-NEXT: bb.4.bb3:
84 ; CHECK-NEXT: [[ADDI5:%[0-9]+]]:gpr = ADDI $x0, 2
85 ; CHECK-NEXT: $x10 = COPY [[ADDI5]]
86 ; CHECK-NEXT: PseudoRET implicit $x10
88 ; CHECK-NEXT: bb.5.bb4:
89 ; CHECK-NEXT: [[ADDI6:%[0-9]+]]:gpr = ADDI $x0, 1
90 ; CHECK-NEXT: $x10 = COPY [[ADDI6]]
91 ; CHECK-NEXT: PseudoRET implicit $x10
93 ; CHECK-NEXT: bb.6.bb5:
94 ; CHECK-NEXT: [[ADDI7:%[0-9]+]]:gpr = ADDI $x0, 100
95 ; CHECK-NEXT: $x10 = COPY [[ADDI7]]
96 ; CHECK-NEXT: PseudoRET implicit $x10
98 ; CHECK-NEXT: bb.7.bb6:
99 ; CHECK-NEXT: [[ADDI8:%[0-9]+]]:gpr = ADDI $x0, 200
100 ; CHECK-NEXT: $x10 = COPY [[ADDI8]]
101 ; CHECK-NEXT: PseudoRET implicit $x10
103 ; CHECK-NEXT: bb.8.default:
104 ; CHECK-NEXT: [[ADDI9:%[0-9]+]]:gpr = ADDI $x0, 1000
105 ; CHECK-NEXT: $x10 = COPY [[ADDI9]]
106 ; CHECK-NEXT: PseudoRET implicit $x10
108 successors: %bb.8, %bb.9
111 %1:gprb(s64) = COPY $x10
112 %2:gprb(s64) = G_ASSERT_SEXT %1, 32
113 %7:gprb(s64) = G_CONSTANT i64 5
114 %3:gprb(s64) = G_SEXT_INREG %2, 32
115 %4:gprb(s64) = G_CONSTANT i64 1
116 %5:gprb(s64) = G_SUB %3, %4
117 %26:gprb(s64) = G_ICMP intpred(ugt), %5(s64), %7
118 G_BRCOND %26(s64), %bb.8
121 successors: %bb.2, %bb.3, %bb.4, %bb.5, %bb.6, %bb.7
123 %10:gprb(p0) = G_JUMP_TABLE %jump-table.0
124 G_BRJT %10(p0), %jump-table.0, %5(s64)
127 %22:gprb(s64) = G_CONSTANT i64 4
129 PseudoRET implicit $x10
132 %20:gprb(s64) = G_CONSTANT i64 3
134 PseudoRET implicit $x10
137 %18:gprb(s64) = G_CONSTANT i64 2
139 PseudoRET implicit $x10
142 %16:gprb(s64) = G_CONSTANT i64 1
144 PseudoRET implicit $x10
147 %14:gprb(s64) = G_CONSTANT i64 100
149 PseudoRET implicit $x10
152 %12:gprb(s64) = G_CONSTANT i64 200
154 PseudoRET implicit $x10
157 %24:gprb(s64) = G_CONSTANT i64 1000
159 PseudoRET implicit $x10