1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefixes=CHECK32I %s
4 ; RUN: llc -mtriple=riscv32 -mattr=+zcmp -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefixes=CHECK32ZCMP %s
6 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
7 ; RUN: | FileCheck -check-prefixes=CHECK64I %s
8 ; RUN: llc -mtriple=riscv64 -mattr=+zcmp -verify-machineinstrs < %s \
9 ; RUN: | FileCheck -check-prefixes=CHECK64ZCMP %s
12 declare i32 @func(i32,i32)
14 define i32 @zcmp_mv(i32 %num, i32 %f) nounwind {
15 ; CHECK32I-LABEL: zcmp_mv:
17 ; CHECK32I-NEXT: addi sp, sp, -16
18 ; CHECK32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
19 ; CHECK32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
20 ; CHECK32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
21 ; CHECK32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill
22 ; CHECK32I-NEXT: mv s0, a1
23 ; CHECK32I-NEXT: mv s1, a0
24 ; CHECK32I-NEXT: call func
25 ; CHECK32I-NEXT: mv s2, a0
26 ; CHECK32I-NEXT: mv a0, s1
27 ; CHECK32I-NEXT: mv a1, s0
28 ; CHECK32I-NEXT: call func
29 ; CHECK32I-NEXT: add a0, s2, s0
30 ; CHECK32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
31 ; CHECK32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
32 ; CHECK32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
33 ; CHECK32I-NEXT: lw s2, 0(sp) # 4-byte Folded Reload
34 ; CHECK32I-NEXT: addi sp, sp, 16
37 ; CHECK32ZCMP-LABEL: zcmp_mv:
38 ; CHECK32ZCMP: # %bb.0:
39 ; CHECK32ZCMP-NEXT: cm.push {ra, s0-s2}, -16
40 ; CHECK32ZCMP-NEXT: cm.mvsa01 s1, s0
41 ; CHECK32ZCMP-NEXT: call func
42 ; CHECK32ZCMP-NEXT: mv s2, a0
43 ; CHECK32ZCMP-NEXT: cm.mva01s s1, s0
44 ; CHECK32ZCMP-NEXT: call func
45 ; CHECK32ZCMP-NEXT: add a0, s2, s0
46 ; CHECK32ZCMP-NEXT: cm.popret {ra, s0-s2}, 16
48 ; CHECK64I-LABEL: zcmp_mv:
50 ; CHECK64I-NEXT: addi sp, sp, -32
51 ; CHECK64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
52 ; CHECK64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
53 ; CHECK64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
54 ; CHECK64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
55 ; CHECK64I-NEXT: mv s0, a1
56 ; CHECK64I-NEXT: mv s1, a0
57 ; CHECK64I-NEXT: call func
58 ; CHECK64I-NEXT: mv s2, a0
59 ; CHECK64I-NEXT: mv a0, s1
60 ; CHECK64I-NEXT: mv a1, s0
61 ; CHECK64I-NEXT: call func
62 ; CHECK64I-NEXT: addw a0, s2, s0
63 ; CHECK64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
64 ; CHECK64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
65 ; CHECK64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
66 ; CHECK64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
67 ; CHECK64I-NEXT: addi sp, sp, 32
70 ; CHECK64ZCMP-LABEL: zcmp_mv:
71 ; CHECK64ZCMP: # %bb.0:
72 ; CHECK64ZCMP-NEXT: cm.push {ra, s0-s2}, -32
73 ; CHECK64ZCMP-NEXT: cm.mvsa01 s1, s0
74 ; CHECK64ZCMP-NEXT: call func
75 ; CHECK64ZCMP-NEXT: mv s2, a0
76 ; CHECK64ZCMP-NEXT: cm.mva01s s1, s0
77 ; CHECK64ZCMP-NEXT: call func
78 ; CHECK64ZCMP-NEXT: addw a0, s2, s0
79 ; CHECK64ZCMP-NEXT: cm.popret {ra, s0-s2}, 32
80 %call = call i32 @func(i32 %num, i32 %f)
81 %call1 = call i32 @func(i32 %num, i32 %f)
82 %res = add i32 %call, %f
86 define i32 @not_zcmp_mv(i32 %num, i32 %f) nounwind {
87 ; CHECK32I-LABEL: not_zcmp_mv:
89 ; CHECK32I-NEXT: addi sp, sp, -16
90 ; CHECK32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
91 ; CHECK32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
92 ; CHECK32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
93 ; CHECK32I-NEXT: mv s0, a1
94 ; CHECK32I-NEXT: call foo
95 ; CHECK32I-NEXT: mv s1, a0
96 ; CHECK32I-NEXT: mv a0, s0
97 ; CHECK32I-NEXT: call foo
98 ; CHECK32I-NEXT: mv a0, s1
99 ; CHECK32I-NEXT: call foo
100 ; CHECK32I-NEXT: li a0, 1
101 ; CHECK32I-NEXT: mv a1, s0
102 ; CHECK32I-NEXT: call func
103 ; CHECK32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
104 ; CHECK32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
105 ; CHECK32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
106 ; CHECK32I-NEXT: addi sp, sp, 16
109 ; CHECK32ZCMP-LABEL: not_zcmp_mv:
110 ; CHECK32ZCMP: # %bb.0:
111 ; CHECK32ZCMP-NEXT: cm.push {ra, s0-s1}, -16
112 ; CHECK32ZCMP-NEXT: mv s0, a1
113 ; CHECK32ZCMP-NEXT: call foo
114 ; CHECK32ZCMP-NEXT: mv s1, a0
115 ; CHECK32ZCMP-NEXT: mv a0, s0
116 ; CHECK32ZCMP-NEXT: call foo
117 ; CHECK32ZCMP-NEXT: mv a0, s1
118 ; CHECK32ZCMP-NEXT: call foo
119 ; CHECK32ZCMP-NEXT: li a0, 1
120 ; CHECK32ZCMP-NEXT: mv a1, s0
121 ; CHECK32ZCMP-NEXT: call func
122 ; CHECK32ZCMP-NEXT: cm.popret {ra, s0-s1}, 16
124 ; CHECK64I-LABEL: not_zcmp_mv:
126 ; CHECK64I-NEXT: addi sp, sp, -32
127 ; CHECK64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
128 ; CHECK64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
129 ; CHECK64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
130 ; CHECK64I-NEXT: mv s0, a1
131 ; CHECK64I-NEXT: call foo
132 ; CHECK64I-NEXT: mv s1, a0
133 ; CHECK64I-NEXT: mv a0, s0
134 ; CHECK64I-NEXT: call foo
135 ; CHECK64I-NEXT: mv a0, s1
136 ; CHECK64I-NEXT: call foo
137 ; CHECK64I-NEXT: li a0, 1
138 ; CHECK64I-NEXT: mv a1, s0
139 ; CHECK64I-NEXT: call func
140 ; CHECK64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
141 ; CHECK64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
142 ; CHECK64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
143 ; CHECK64I-NEXT: addi sp, sp, 32
146 ; CHECK64ZCMP-LABEL: not_zcmp_mv:
147 ; CHECK64ZCMP: # %bb.0:
148 ; CHECK64ZCMP-NEXT: cm.push {ra, s0-s1}, -32
149 ; CHECK64ZCMP-NEXT: mv s0, a1
150 ; CHECK64ZCMP-NEXT: call foo
151 ; CHECK64ZCMP-NEXT: mv s1, a0
152 ; CHECK64ZCMP-NEXT: mv a0, s0
153 ; CHECK64ZCMP-NEXT: call foo
154 ; CHECK64ZCMP-NEXT: mv a0, s1
155 ; CHECK64ZCMP-NEXT: call foo
156 ; CHECK64ZCMP-NEXT: li a0, 1
157 ; CHECK64ZCMP-NEXT: mv a1, s0
158 ; CHECK64ZCMP-NEXT: call func
159 ; CHECK64ZCMP-NEXT: cm.popret {ra, s0-s1}, 32
160 %call = call i32 @foo(i32 %num)
161 %call1 = call i32 @foo(i32 %f)
162 %tmp = call i32 @foo(i32 %call)
163 %res = call i32 @func(i32 1, i32 %f)