xref: /llvm-project/llvm/test/CodeGen/RISCV/zcmp-with-float.ll (revision eabaee0c59110d0e11b33a69db54ccda526b35fd)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2; RUN: llc -mtriple=riscv32 -mattr=+f,+zcmp -target-abi ilp32f -verify-machineinstrs < %s | FileCheck %s --check-prefix=RV32
3; RUN: llc -mtriple=riscv64 -mattr=+f,+zcmp -target-abi lp64f -verify-machineinstrs < %s | FileCheck %s --check-prefix=RV64
4
5declare void @callee()
6
7; Test the file could be compiled successfully.
8; .cfi_offset of fs0 is wrong here. It should be fixed by #66613.
9define float @foo(float %arg) {
10; RV32-LABEL: foo:
11; RV32:       # %bb.0: # %entry
12; RV32-NEXT:    cm.push {ra}, -32
13; RV32-NEXT:    .cfi_def_cfa_offset 32
14; RV32-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
15; RV32-NEXT:    .cfi_offset ra, -4
16; RV32-NEXT:    .cfi_offset fs0, -20
17; RV32-NEXT:    fmv.s fs0, fa0
18; RV32-NEXT:    call callee
19; RV32-NEXT:    fmv.s fa0, fs0
20; RV32-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
21; RV32-NEXT:    cm.popret {ra}, 32
22;
23; RV64-LABEL: foo:
24; RV64:       # %bb.0: # %entry
25; RV64-NEXT:    cm.push {ra}, -32
26; RV64-NEXT:    .cfi_def_cfa_offset 32
27; RV64-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
28; RV64-NEXT:    .cfi_offset ra, -8
29; RV64-NEXT:    .cfi_offset fs0, -20
30; RV64-NEXT:    fmv.s fs0, fa0
31; RV64-NEXT:    call callee
32; RV64-NEXT:    fmv.s fa0, fs0
33; RV64-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
34; RV64-NEXT:    cm.popret {ra}, 32
35entry:
36  call void @callee()
37  ret float %arg
38}
39
40define void @foo2(i32 %x, float %y) {
41; RV32-LABEL: foo2:
42; RV32:       # %bb.0: # %entry
43; RV32-NEXT:    cm.push {ra, s0}, -32
44; RV32-NEXT:    .cfi_def_cfa_offset 32
45; RV32-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
46; RV32-NEXT:    .cfi_offset ra, -8
47; RV32-NEXT:    .cfi_offset s0, -4
48; RV32-NEXT:    .cfi_offset fs0, -20
49; RV32-NEXT:    fmv.s fs0, fa0
50; RV32-NEXT:    mv s0, a0
51; RV32-NEXT:    call bar
52; RV32-NEXT:    mv a0, s0
53; RV32-NEXT:    fmv.s fa0, fs0
54; RV32-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
55; RV32-NEXT:    cm.pop {ra, s0}, 32
56; RV32-NEXT:    tail func
57;
58; RV64-LABEL: foo2:
59; RV64:       # %bb.0: # %entry
60; RV64-NEXT:    cm.push {ra, s0}, -32
61; RV64-NEXT:    .cfi_def_cfa_offset 32
62; RV64-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
63; RV64-NEXT:    .cfi_offset ra, -16
64; RV64-NEXT:    .cfi_offset s0, -8
65; RV64-NEXT:    .cfi_offset fs0, -20
66; RV64-NEXT:    fmv.s fs0, fa0
67; RV64-NEXT:    mv s0, a0
68; RV64-NEXT:    call bar
69; RV64-NEXT:    mv a0, s0
70; RV64-NEXT:    fmv.s fa0, fs0
71; RV64-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
72; RV64-NEXT:    cm.pop {ra, s0}, 32
73; RV64-NEXT:    tail func
74entry:
75  tail call void @bar()
76  tail call void @func(i32 %x, float %y)
77  ret void
78}
79
80declare void @bar()
81declare void @func(i32, float)
82