xref: /llvm-project/llvm/test/CodeGen/RISCV/fli-licm.ll (revision ff9af4c43ad71eeba2cabe99609cfaa0fd54c1d0)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2; RUN: llc < %s -mtriple=riscv32 -target-abi=ilp32f -mattr=+zfa \
3; RUN:   | FileCheck %s --check-prefix=RV32
4; RUN: llc < %s -mtriple=riscv64 -target-abi=lp64f -mattr=+zfa \
5; RUN:   | FileCheck %s --check-prefix=RV64
6
7; The purpose of this test is to check that an FLI instruction that
8; materializes an immediate is not MachineLICM'd out of a loop.
9
10%struct.Node = type { ptr, ptr }
11
12define void @process_nodes(ptr %0) nounwind {
13; RV32-LABEL: process_nodes:
14; RV32:       # %bb.0: # %entry
15; RV32-NEXT:    beqz a0, .LBB0_4
16; RV32-NEXT:  # %bb.1: # %loop.preheader
17; RV32-NEXT:    addi sp, sp, -16
18; RV32-NEXT:    sw ra, 12(sp) # 4-byte Folded Spill
19; RV32-NEXT:    sw s0, 8(sp) # 4-byte Folded Spill
20; RV32-NEXT:    mv s0, a0
21; RV32-NEXT:  .LBB0_2: # %loop
22; RV32-NEXT:    # =>This Inner Loop Header: Depth=1
23; RV32-NEXT:    fli.s fa0, 1.0
24; RV32-NEXT:    mv a0, s0
25; RV32-NEXT:    call do_it
26; RV32-NEXT:    lw s0, 0(s0)
27; RV32-NEXT:    bnez s0, .LBB0_2
28; RV32-NEXT:  # %bb.3:
29; RV32-NEXT:    lw ra, 12(sp) # 4-byte Folded Reload
30; RV32-NEXT:    lw s0, 8(sp) # 4-byte Folded Reload
31; RV32-NEXT:    addi sp, sp, 16
32; RV32-NEXT:  .LBB0_4: # %exit
33; RV32-NEXT:    ret
34;
35; RV64-LABEL: process_nodes:
36; RV64:       # %bb.0: # %entry
37; RV64-NEXT:    beqz a0, .LBB0_4
38; RV64-NEXT:  # %bb.1: # %loop.preheader
39; RV64-NEXT:    addi sp, sp, -16
40; RV64-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
41; RV64-NEXT:    sd s0, 0(sp) # 8-byte Folded Spill
42; RV64-NEXT:    mv s0, a0
43; RV64-NEXT:  .LBB0_2: # %loop
44; RV64-NEXT:    # =>This Inner Loop Header: Depth=1
45; RV64-NEXT:    fli.s fa0, 1.0
46; RV64-NEXT:    mv a0, s0
47; RV64-NEXT:    call do_it
48; RV64-NEXT:    ld s0, 0(s0)
49; RV64-NEXT:    bnez s0, .LBB0_2
50; RV64-NEXT:  # %bb.3:
51; RV64-NEXT:    ld ra, 8(sp) # 8-byte Folded Reload
52; RV64-NEXT:    ld s0, 0(sp) # 8-byte Folded Reload
53; RV64-NEXT:    addi sp, sp, 16
54; RV64-NEXT:  .LBB0_4: # %exit
55; RV64-NEXT:    ret
56entry:
57  %1 = icmp eq ptr %0, null
58  br i1 %1, label %exit, label %loop
59
60loop:
61  %2 = phi ptr [ %4, %loop ], [ %0, %entry ]
62  tail call void @do_it(float 1.000000e+00, ptr nonnull %2)
63  %3 = getelementptr inbounds %struct.Node, ptr %2, i64 0, i32 0
64  %4 = load ptr, ptr %3, align 8
65  %5 = icmp eq ptr %4, null
66  br i1 %5, label %exit, label %loop
67
68exit:
69  ret void
70}
71
72declare void @do_it(float, ptr)
73