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