1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64 -stop-after=finalize-isel < %s | FileCheck %s
4 define dso_local void @buz(i1 %pred, float %a, float %b) {
5 ; CHECK-LABEL: name: buz
7 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
8 ; CHECK-NEXT: liveins: $x10, $x11, $x12
10 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x12
11 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
12 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr = COPY $x10
13 ; CHECK-NEXT: [[FMV_W_X:%[0-9]+]]:fpr32 = FMV_W_X [[COPY]]
14 ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[COPY2]], 1
15 ; CHECK-NEXT: [[FMV_W_X1:%[0-9]+]]:fpr32 = FMV_W_X [[COPY1]]
16 ; CHECK-NEXT: [[LUI:%[0-9]+]]:gpr = LUI 307200
17 ; CHECK-NEXT: [[FMV_W_X2:%[0-9]+]]:fpr32 = FMV_W_X killed [[LUI]]
18 ; CHECK-NEXT: [[FSGNJX_S:%[0-9]+]]:fpr32 = FSGNJX_S [[FMV_W_X1]], [[FMV_W_X1]]
19 ; CHECK-NEXT: [[FLT_S:%[0-9]+]]:gpr = nofpexcept FLT_S [[FSGNJX_S]], [[FMV_W_X2]]
20 ; CHECK-NEXT: BEQ [[FLT_S]], $x0, %bb.2
22 ; CHECK-NEXT: bb.1.entry:
23 ; CHECK-NEXT: successors: %bb.2(0x80000000)
25 ; CHECK-NEXT: [[FCVT_W_S:%[0-9]+]]:gpr = nofpexcept FCVT_W_S [[FMV_W_X1]], 4
26 ; CHECK-NEXT: [[FCVT_S_W:%[0-9]+]]:fpr32 = nofpexcept FCVT_S_W [[FCVT_W_S]], 4
27 ; CHECK-NEXT: [[FSGNJ_S:%[0-9]+]]:fpr32 = FSGNJ_S [[FCVT_S_W]], [[FMV_W_X1]]
29 ; CHECK-NEXT: bb.2.entry:
30 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
32 ; CHECK-NEXT: [[PHI:%[0-9]+]]:fpr32 = PHI [[FMV_W_X1]], %bb.0, [[FSGNJ_S]], %bb.1
33 ; CHECK-NEXT: BNE [[ANDI]], $x0, %bb.4
35 ; CHECK-NEXT: bb.3.entry:
36 ; CHECK-NEXT: successors: %bb.4(0x80000000)
39 ; CHECK-NEXT: bb.4.entry:
40 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.6(0x40000000)
42 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:fpr32 = PHI [[PHI]], %bb.2, [[FMV_W_X1]], %bb.3
43 ; CHECK-NEXT: [[FSGNJX_S1:%[0-9]+]]:fpr32 = FSGNJX_S [[FMV_W_X]], [[FMV_W_X]]
44 ; CHECK-NEXT: [[FLT_S1:%[0-9]+]]:gpr = nofpexcept FLT_S [[FSGNJX_S1]], [[FMV_W_X2]]
45 ; CHECK-NEXT: BEQ [[FLT_S1]], $x0, %bb.6
47 ; CHECK-NEXT: bb.5.entry:
48 ; CHECK-NEXT: successors: %bb.6(0x80000000)
50 ; CHECK-NEXT: [[FCVT_W_S1:%[0-9]+]]:gpr = nofpexcept FCVT_W_S [[FMV_W_X]], 4
51 ; CHECK-NEXT: [[FCVT_S_W1:%[0-9]+]]:fpr32 = nofpexcept FCVT_S_W [[FCVT_W_S1]], 4
52 ; CHECK-NEXT: [[FSGNJ_S1:%[0-9]+]]:fpr32 = FSGNJ_S [[FCVT_S_W1]], [[FMV_W_X]]
54 ; CHECK-NEXT: bb.6.entry:
55 ; CHECK-NEXT: successors: %bb.7(0x40000000), %bb.8(0x40000000)
57 ; CHECK-NEXT: [[PHI2:%[0-9]+]]:fpr32 = PHI [[FMV_W_X]], %bb.4, [[FSGNJ_S1]], %bb.5
58 ; CHECK-NEXT: BNE [[ANDI]], $x0, %bb.8
60 ; CHECK-NEXT: bb.7.entry:
61 ; CHECK-NEXT: successors: %bb.8(0x80000000)
64 ; CHECK-NEXT: bb.8.entry:
65 ; CHECK-NEXT: [[PHI3:%[0-9]+]]:fpr32 = PHI [[PHI2]], %bb.6, [[FMV_W_X]], %bb.7
66 ; CHECK-NEXT: [[FCVT_L_S:%[0-9]+]]:gpr = nofpexcept FCVT_L_S killed [[PHI3]], 1
67 ; CHECK-NEXT: [[FMV_X_W:%[0-9]+]]:gpr = FMV_X_W killed [[PHI1]]
68 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
69 ; CHECK-NEXT: $x10 = COPY [[FMV_X_W]]
70 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) @bar, csr_ilp32_lp64, implicit-def dead $x1, implicit $x10, implicit-def $x2
71 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
72 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2
73 ; CHECK-NEXT: $x10 = COPY [[FCVT_L_S]]
74 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) @foo, csr_ilp32_lp64, implicit-def dead $x1, implicit $x10, implicit-def $x2
75 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2
76 ; CHECK-NEXT: PseudoRET
78 %0 = call float @llvm.round.f32(float %a)
79 %cond = select i1 %pred, float %0, float %a
80 %1 = call float @llvm.round.f32(float %b)
81 %cond2 = select i1 %pred, float %1, float %b
82 %conv = fptosi float %cond2 to i64
83 call void @bar(float %cond)
84 call void @foo(i64 %conv)
88 declare void @foo(i64)
90 declare void @bar(float)
92 declare float @llvm.round.f32(float)