1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple riscv64 < %s | FileCheck %s
4 declare signext i32 @func1(ptr noundef) local_unnamed_addr
5 declare signext i32 @func2(ptr noundef) local_unnamed_addr
6 declare signext i32 @func3(ptr noundef) local_unnamed_addr
7 declare signext i32 @func4(ptr noundef) local_unnamed_addr
8 declare signext i32 @func5(ptr noundef) local_unnamed_addr
9 declare signext i32 @default_func(ptr noundef) local_unnamed_addr
11 define dso_local signext i32 @test_shrinkwrap_jump_table(ptr noundef %m) local_unnamed_addr {
12 ; CHECK-LABEL: test_shrinkwrap_jump_table:
13 ; CHECK: # %bb.0: # %entry
14 ; CHECK-NEXT: lw a1, 0(a0)
15 ; CHECK-NEXT: addi a1, a1, -1
16 ; CHECK-NEXT: li a2, 4
17 ; CHECK-NEXT: bltu a2, a1, .LBB0_7
18 ; CHECK-NEXT: # %bb.1: # %entry
19 ; CHECK-NEXT: slli a1, a1, 2
20 ; CHECK-NEXT: lui a2, %hi(.LJTI0_0)
21 ; CHECK-NEXT: addi a2, a2, %lo(.LJTI0_0)
22 ; CHECK-NEXT: add a1, a1, a2
23 ; CHECK-NEXT: lw a1, 0(a1)
25 ; CHECK-NEXT: .LBB0_2: # %sw.bb
26 ; CHECK-NEXT: tail func1
27 ; CHECK-NEXT: .LBB0_3: # %sw.bb7
28 ; CHECK-NEXT: tail func5
29 ; CHECK-NEXT: .LBB0_4: # %sw.bb3
30 ; CHECK-NEXT: tail func3
31 ; CHECK-NEXT: .LBB0_5: # %sw.bb5
32 ; CHECK-NEXT: tail func4
33 ; CHECK-NEXT: .LBB0_6: # %sw.bb1
34 ; CHECK-NEXT: tail func2
35 ; CHECK-NEXT: .LBB0_7: # %sw.default
36 ; CHECK-NEXT: addi sp, sp, -16
37 ; CHECK-NEXT: .cfi_def_cfa_offset 16
38 ; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
39 ; CHECK-NEXT: .cfi_offset ra, -8
40 ; CHECK-NEXT: call default_func
41 ; CHECK-NEXT: li a0, 0
42 ; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
43 ; CHECK-NEXT: addi sp, sp, 16
46 %0 = load i32, ptr %m, align 4
47 switch i32 %0, label %sw.default [
56 %call = tail call signext i32 @func1(ptr noundef nonnull %m)
60 %call2 = tail call signext i32 @func2(ptr noundef nonnull %m)
64 %call4 = tail call signext i32 @func3(ptr noundef nonnull %m)
68 %call6 = tail call signext i32 @func4(ptr noundef nonnull %m)
72 %call8 = tail call signext i32 @func5(ptr noundef nonnull %m)
76 %call9 = tail call signext i32 @default_func(ptr noundef nonnull %m)
80 %ret.0 = phi i32 [ 0, %sw.default ], [ %call8, %sw.bb7 ], [ %call6, %sw.bb5 ], [ %call4, %sw.bb3 ], [ %call2, %sw.bb1 ], [ %call, %sw.bb ]