1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs -mcpu=syntacore-scr1-max \
3 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=local < %s | \
4 ; RUN: FileCheck %s --check-prefixes=CHECK_LOCAL_SCR1
6 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs -mcpu=syntacore-scr1-max \
7 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=min-instr < %s | \
8 ; RUN: FileCheck %s --check-prefixes=CHECK_GLOBAL_SCR1
10 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs -mcpu=sifive-u74 \
11 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=local < %s | \
12 ; RUN: FileCheck %s --check-prefixes=CHECK_LOCAL_SIFIVE_U74
14 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs -mcpu=sifive-u74 \
15 ; RUN: -O1 -riscv-enable-machine-combiner=true -riscv-force-machine-combiner-strategy=min-instr < %s | \
16 ; RUN: FileCheck %s --check-prefixes=CHECK_GLOBAL_SIFIVE_U74
18 define i32 @test_local_strategy(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5) {
19 ; CHECK_LOCAL_SCR1-LABEL: test_local_strategy:
20 ; CHECK_LOCAL_SCR1: # %bb.0: # %entry
21 ; CHECK_LOCAL_SCR1-NEXT: div a0, a0, a1
22 ; CHECK_LOCAL_SCR1-NEXT: sub a0, a0, a2
23 ; CHECK_LOCAL_SCR1-NEXT: beqz a0, .LBB0_2
24 ; CHECK_LOCAL_SCR1-NEXT: # %bb.1: # %b2
25 ; CHECK_LOCAL_SCR1-NEXT: ret
26 ; CHECK_LOCAL_SCR1-NEXT: .LBB0_2: # %b1
27 ; CHECK_LOCAL_SCR1-NEXT: add a3, a3, a4
28 ; CHECK_LOCAL_SCR1-NEXT: add a0, a0, a5
29 ; CHECK_LOCAL_SCR1-NEXT: add a0, a0, a3
30 ; CHECK_LOCAL_SCR1-NEXT: ret
32 ; CHECK_GLOBAL_SCR1-LABEL: test_local_strategy:
33 ; CHECK_GLOBAL_SCR1: # %bb.0: # %entry
34 ; CHECK_GLOBAL_SCR1-NEXT: div a0, a0, a1
35 ; CHECK_GLOBAL_SCR1-NEXT: sub a0, a0, a2
36 ; CHECK_GLOBAL_SCR1-NEXT: beqz a0, .LBB0_2
37 ; CHECK_GLOBAL_SCR1-NEXT: # %bb.1: # %b2
38 ; CHECK_GLOBAL_SCR1-NEXT: ret
39 ; CHECK_GLOBAL_SCR1-NEXT: .LBB0_2: # %b1
40 ; CHECK_GLOBAL_SCR1-NEXT: add a3, a3, a4
41 ; CHECK_GLOBAL_SCR1-NEXT: add a3, a3, a5
42 ; CHECK_GLOBAL_SCR1-NEXT: add a0, a0, a3
43 ; CHECK_GLOBAL_SCR1-NEXT: ret
45 ; CHECK_LOCAL_SIFIVE_U74-LABEL: test_local_strategy:
46 ; CHECK_LOCAL_SIFIVE_U74: # %bb.0: # %entry
47 ; CHECK_LOCAL_SIFIVE_U74-NEXT: divw a0, a0, a1
48 ; CHECK_LOCAL_SIFIVE_U74-NEXT: subw a0, a0, a2
49 ; CHECK_LOCAL_SIFIVE_U74-NEXT: beqz a0, .LBB0_2
50 ; CHECK_LOCAL_SIFIVE_U74-NEXT: # %bb.1: # %b2
51 ; CHECK_LOCAL_SIFIVE_U74-NEXT: ret
52 ; CHECK_LOCAL_SIFIVE_U74-NEXT: .LBB0_2: # %b1
53 ; CHECK_LOCAL_SIFIVE_U74-NEXT: add a3, a3, a4
54 ; CHECK_LOCAL_SIFIVE_U74-NEXT: add a0, a0, a5
55 ; CHECK_LOCAL_SIFIVE_U74-NEXT: addw a0, a0, a3
56 ; CHECK_LOCAL_SIFIVE_U74-NEXT: ret
58 ; CHECK_GLOBAL_SIFIVE_U74-LABEL: test_local_strategy:
59 ; CHECK_GLOBAL_SIFIVE_U74: # %bb.0: # %entry
60 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: divw a0, a0, a1
61 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: subw a0, a0, a2
62 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: beqz a0, .LBB0_2
63 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: # %bb.1: # %b2
64 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: ret
65 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: .LBB0_2: # %b1
66 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: add a3, a3, a4
67 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: add a3, a3, a5
68 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: addw a0, a0, a3
69 ; CHECK_GLOBAL_SIFIVE_U74-NEXT: ret
71 %div = sdiv i32 %a0, %a1
72 %sub0 = sub i32 %div, %a2
73 %cmp = icmp eq i32 %sub0, 0
74 br i1 %cmp, label %b1, label %b2
76 %sub1 = add i32 %a3, %a4
77 %sub2 = add i32 %a5, %sub1
78 %sub3 = add i32 %sub2, %sub0