xref: /llvm-project/llvm/test/CodeGen/RISCV/zcmp-with-float.ll (revision 97982a8c605fac7c86d02e641a6cd7898b3ca343)
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.
8define float @foo(float %arg) {
9; RV32-LABEL: foo:
10; RV32:       # %bb.0: # %entry
11; RV32-NEXT:    cm.push {ra}, -32
12; RV32-NEXT:    .cfi_def_cfa_offset 32
13; RV32-NEXT:    .cfi_offset ra, -4
14; RV32-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
15; RV32-NEXT:    .cfi_offset fs0, -20
16; RV32-NEXT:    fmv.s fs0, fa0
17; RV32-NEXT:    call callee
18; RV32-NEXT:    fmv.s fa0, fs0
19; RV32-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
20; RV32-NEXT:    .cfi_restore fs0
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:    .cfi_offset ra, -8
28; RV64-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
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:    .cfi_restore fs0
35; RV64-NEXT:    cm.popret {ra}, 32
36entry:
37  call void @callee()
38  ret float %arg
39}
40
41define void @foo2(i32 %x, float %y) {
42; RV32-LABEL: foo2:
43; RV32:       # %bb.0: # %entry
44; RV32-NEXT:    cm.push {ra, s0}, -32
45; RV32-NEXT:    .cfi_def_cfa_offset 32
46; RV32-NEXT:    .cfi_offset ra, -8
47; RV32-NEXT:    .cfi_offset s0, -4
48; RV32-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
49; RV32-NEXT:    .cfi_offset fs0, -20
50; RV32-NEXT:    fmv.s fs0, fa0
51; RV32-NEXT:    mv s0, a0
52; RV32-NEXT:    call bar
53; RV32-NEXT:    mv a0, s0
54; RV32-NEXT:    fmv.s fa0, fs0
55; RV32-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
56; RV32-NEXT:    .cfi_restore fs0
57; RV32-NEXT:    cm.pop {ra, s0}, 32
58; RV32-NEXT:    .cfi_restore ra
59; RV32-NEXT:    .cfi_restore s0
60; RV32-NEXT:    .cfi_def_cfa_offset 0
61; RV32-NEXT:    tail func
62;
63; RV64-LABEL: foo2:
64; RV64:       # %bb.0: # %entry
65; RV64-NEXT:    cm.push {ra, s0}, -32
66; RV64-NEXT:    .cfi_def_cfa_offset 32
67; RV64-NEXT:    .cfi_offset ra, -16
68; RV64-NEXT:    .cfi_offset s0, -8
69; RV64-NEXT:    fsw fs0, 12(sp) # 4-byte Folded Spill
70; RV64-NEXT:    .cfi_offset fs0, -20
71; RV64-NEXT:    fmv.s fs0, fa0
72; RV64-NEXT:    mv s0, a0
73; RV64-NEXT:    call bar
74; RV64-NEXT:    mv a0, s0
75; RV64-NEXT:    fmv.s fa0, fs0
76; RV64-NEXT:    flw fs0, 12(sp) # 4-byte Folded Reload
77; RV64-NEXT:    .cfi_restore fs0
78; RV64-NEXT:    cm.pop {ra, s0}, 32
79; RV64-NEXT:    .cfi_restore ra
80; RV64-NEXT:    .cfi_restore s0
81; RV64-NEXT:    .cfi_def_cfa_offset 0
82; RV64-NEXT:    tail func
83entry:
84  tail call void @bar()
85  tail call void @func(i32 %x, float %y)
86  ret void
87}
88
89declare void @bar()
90declare void @func(i32, float)
91