1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-unknown-unknown -o - -verify-machineinstrs -run-pass=instruction-select %s | FileCheck %s
4 define i32 @jt_test(i32 %x) {
6 switch i32 %x, label %return [
18 %add = add nsw i32 %x, 42
22 %mul = mul nsw i32 %x, 3
26 %retval.0 = phi i32 [ %mul, %sw.bb1 ], [ %add, %sw.bb ], [ 0, %entry ]
36 tracksRegLiveness: true
37 machineFunctionInfo: {}
42 blocks: [ '%bb.3', '%bb.3', '%bb.3', '%bb.4', '%bb.4', '%bb.4',
43 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
44 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
45 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
46 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
47 '%bb.2', '%bb.2', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
48 '%bb.2', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
49 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
50 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.2', '%bb.4',
51 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
52 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4',
53 '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.2' ]
55 ; CHECK-LABEL: name: jt_test
57 ; CHECK: successors: %bb.4(0x40000000), %bb.1(0x40000000)
59 ; CHECK: [[COPY:%[0-9]+]]:gpr32common = COPY $w0
60 ; CHECK: [[MOVi32imm:%[0-9]+]]:gpr32 = COPY $wzr
61 ; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 4, 0, implicit-def $nzcv
62 ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[SUBSWri]], %subreg.sub_32
63 ; CHECK: [[UBFMXri:%[0-9]+]]:gpr64common = UBFMXri [[SUBREG_TO_REG]], 0, 31
64 ; CHECK: $xzr = SUBSXri [[UBFMXri]], 71, 0, implicit-def $nzcv
65 ; CHECK: Bcc 8, %bb.4, implicit $nzcv
67 ; CHECK: successors: %bb.3(0x2aaaaaab), %bb.4(0x2aaaaaab), %bb.2(0x2aaaaaab)
68 ; CHECK: [[MOVi32imm1:%[0-9]+]]:gpr32 = COPY $wzr
69 ; CHECK: [[MOVaddrJT:%[0-9]+]]:gpr64 = MOVaddrJT target-flags(aarch64-page) %jump-table.0, target-flags(aarch64-pageoff, aarch64-nc) %jump-table.0
70 ; CHECK: early-clobber %18:gpr64, early-clobber %19:gpr64sp = JumpTableDest32 [[MOVaddrJT]], [[UBFMXri]], %jump-table.0
73 ; CHECK: successors: %bb.4(0x80000000)
74 ; CHECK: [[ADDWri:%[0-9]+]]:gpr32sp = ADDWri [[COPY]], 42, 0
77 ; CHECK: successors: %bb.4(0x80000000)
78 ; CHECK: [[MOVi32imm2:%[0-9]+]]:gpr32 = MOVi32imm 3
79 ; CHECK: [[MADDWrrr:%[0-9]+]]:gpr32 = MADDWrrr [[COPY]], [[MOVi32imm2]], $wzr
81 ; CHECK: [[PHI:%[0-9]+]]:gpr32 = PHI [[MADDWrrr]], %bb.3, [[ADDWri]], %bb.2, [[MOVi32imm]], %bb.0, [[MOVi32imm1]], %bb.1
82 ; CHECK: $w0 = COPY [[PHI]]
83 ; CHECK: RET_ReallyLR implicit $w0
87 %0:gpr(s32) = COPY $w0
88 %4:gpr(s32) = G_CONSTANT i32 71
89 %8:gpr(s32) = G_CONSTANT i32 3
90 %10:gpr(s32) = G_CONSTANT i32 42
91 %13:gpr(s32) = G_CONSTANT i32 0
92 %1:gpr(s32) = G_CONSTANT i32 4
93 %2:gpr(s32) = G_SUB %0, %1
94 %3:gpr(s64) = G_ZEXT %2(s32)
95 %5:gpr(s64) = G_ZEXT %4(s32)
96 %14:gpr(s32) = G_ICMP intpred(ugt), %3(s64), %5
97 %6:gpr(s1) = G_TRUNC %14(s32)
98 G_BRCOND %6(s1), %bb.4
101 successors: %bb.3, %bb.4, %bb.2
103 %17:gpr(s32) = G_CONSTANT i32 0
104 %7:gpr(p0) = G_JUMP_TABLE %jump-table.0
105 G_BRJT %7(p0), %jump-table.0, %3(s64)
108 %16:gpr(s32) = G_CONSTANT i32 42
109 %11:gpr(s32) = nsw G_ADD %0, %16
113 %15:gpr(s32) = G_CONSTANT i32 3
114 %9:gpr(s32) = nsw G_MUL %0, %15
117 %12:gpr(s32) = G_PHI %9(s32), %bb.3, %11(s32), %bb.2, %13(s32), %bb.1, %17(s32), %bb.5
119 RET_ReallyLR implicit $w0