1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv32 -global-isel < %s | FileCheck %s --check-prefixes=CHECK,CHECKI,RV32
3 ; RUN: llc -mtriple=riscv64 -global-isel < %s | FileCheck %s --check-prefixes=CHECK,CHECKI,RV64
4 ; RUN: llc -mtriple=riscv32 -mattr=+f -global-isel < %s | FileCheck %s --check-prefixes=CHECK,CHECKIF,RV32
5 ; RUN: llc -mtriple=riscv64 -mattr=+f -global-isel < %s | FileCheck %s --check-prefixes=CHECK,CHECKIF,RV64
7 define i1 @phi_i1(i1 %cnd, i1 %a, i1 %b) {
9 ; CHECK: # %bb.0: # %entry
10 ; CHECK-NEXT: mv a3, a0
11 ; CHECK-NEXT: mv a0, a1
12 ; CHECK-NEXT: andi a3, a3, 1
13 ; CHECK-NEXT: bnez a3, .LBB0_2
14 ; CHECK-NEXT: # %bb.1: # %cond.false
15 ; CHECK-NEXT: mv a0, a2
16 ; CHECK-NEXT: .LBB0_2: # %cond.end
19 br i1 %cnd, label %cond.end, label %cond.false
21 cond.false: ; preds = %entry
24 cond.end: ; preds = %entry, %cond.false
25 %cond = phi i1 [ %b, %cond.false ], [ %a, %entry ]
29 define i8 @phi_i8(i1 %cnd, i8 %a, i8 %b) {
30 ; CHECK-LABEL: phi_i8:
31 ; CHECK: # %bb.0: # %entry
32 ; CHECK-NEXT: mv a3, a0
33 ; CHECK-NEXT: mv a0, a1
34 ; CHECK-NEXT: andi a3, a3, 1
35 ; CHECK-NEXT: bnez a3, .LBB1_2
36 ; CHECK-NEXT: # %bb.1: # %cond.false
37 ; CHECK-NEXT: mv a0, a2
38 ; CHECK-NEXT: .LBB1_2: # %cond.end
41 br i1 %cnd, label %cond.end, label %cond.false
43 cond.false: ; preds = %entry
46 cond.end: ; preds = %entry, %cond.false
47 %cond = phi i8 [ %b, %cond.false ], [ %a, %entry ]
51 define i16 @phi_i16(i1 %cnd, i16 %a, i16 %b) {
52 ; CHECK-LABEL: phi_i16:
53 ; CHECK: # %bb.0: # %entry
54 ; CHECK-NEXT: mv a3, a0
55 ; CHECK-NEXT: mv a0, a1
56 ; CHECK-NEXT: andi a3, a3, 1
57 ; CHECK-NEXT: bnez a3, .LBB2_2
58 ; CHECK-NEXT: # %bb.1: # %cond.false
59 ; CHECK-NEXT: mv a0, a2
60 ; CHECK-NEXT: .LBB2_2: # %cond.end
63 br i1 %cnd, label %cond.end, label %cond.false
65 cond.false: ; preds = %entry
68 cond.end: ; preds = %entry, %cond.false
69 %cond = phi i16 [ %b, %cond.false ], [ %a, %entry ]
73 define i32 @phi_i32(i1 %cnd, i32 %a, i32 %b) {
74 ; CHECK-LABEL: phi_i32:
75 ; CHECK: # %bb.0: # %entry
76 ; CHECK-NEXT: mv a3, a0
77 ; CHECK-NEXT: mv a0, a1
78 ; CHECK-NEXT: andi a3, a3, 1
79 ; CHECK-NEXT: bnez a3, .LBB3_2
80 ; CHECK-NEXT: # %bb.1: # %cond.false
81 ; CHECK-NEXT: mv a0, a2
82 ; CHECK-NEXT: .LBB3_2: # %cond.end
85 br i1 %cnd, label %cond.end, label %cond.false
87 cond.false: ; preds = %entry
90 cond.end: ; preds = %entry, %cond.false
91 %cond = phi i32 [ %b, %cond.false ], [ %a, %entry ]
95 define i64 @phi_i64(i1 %cnd, i64 %a, i64 %b) {
96 ; RV32-LABEL: phi_i64:
97 ; RV32: # %bb.0: # %entry
98 ; RV32-NEXT: mv a5, a0
99 ; RV32-NEXT: mv a0, a1
100 ; RV32-NEXT: mv a1, a2
101 ; RV32-NEXT: andi a5, a5, 1
102 ; RV32-NEXT: bnez a5, .LBB4_2
103 ; RV32-NEXT: # %bb.1: # %cond.false
104 ; RV32-NEXT: mv a0, a3
105 ; RV32-NEXT: mv a1, a4
106 ; RV32-NEXT: .LBB4_2: # %cond.end
109 ; RV64-LABEL: phi_i64:
110 ; RV64: # %bb.0: # %entry
111 ; RV64-NEXT: mv a3, a0
112 ; RV64-NEXT: mv a0, a1
113 ; RV64-NEXT: andi a3, a3, 1
114 ; RV64-NEXT: bnez a3, .LBB4_2
115 ; RV64-NEXT: # %bb.1: # %cond.false
116 ; RV64-NEXT: mv a0, a2
117 ; RV64-NEXT: .LBB4_2: # %cond.end
120 br i1 %cnd, label %cond.end, label %cond.false
122 cond.false: ; preds = %entry
125 cond.end: ; preds = %entry, %cond.false
126 %cond = phi i64 [ %b, %cond.false ], [ %a, %entry ]
130 define ptr @phi_ptr(i1 %cnd, ptr %a, ptr %b) {
131 ; CHECK-LABEL: phi_ptr:
132 ; CHECK: # %bb.0: # %entry
133 ; CHECK-NEXT: mv a3, a0
134 ; CHECK-NEXT: mv a0, a1
135 ; CHECK-NEXT: andi a3, a3, 1
136 ; CHECK-NEXT: bnez a3, .LBB5_2
137 ; CHECK-NEXT: # %bb.1: # %cond.false
138 ; CHECK-NEXT: mv a0, a2
139 ; CHECK-NEXT: .LBB5_2: # %cond.end
142 br i1 %cnd, label %cond.end, label %cond.false
144 cond.false: ; preds = %entry
147 cond.end: ; preds = %entry, %cond.false
148 %cond = phi ptr [ %b, %cond.false ], [ %a, %entry ]
152 define float @phi_float(i1 %cnd, float %a, float %b) {
153 ; CHECKI-LABEL: phi_float:
154 ; CHECKI: # %bb.0: # %entry
155 ; CHECKI-NEXT: mv a3, a0
156 ; CHECKI-NEXT: mv a0, a1
157 ; CHECKI-NEXT: andi a3, a3, 1
158 ; CHECKI-NEXT: bnez a3, .LBB6_2
159 ; CHECKI-NEXT: # %bb.1: # %cond.false
160 ; CHECKI-NEXT: mv a0, a2
161 ; CHECKI-NEXT: .LBB6_2: # %cond.end
164 ; CHECKIF-LABEL: phi_float:
165 ; CHECKIF: # %bb.0: # %entry
166 ; CHECKIF-NEXT: andi a0, a0, 1
167 ; CHECKIF-NEXT: bnez a0, .LBB6_2
168 ; CHECKIF-NEXT: # %bb.1: # %cond.false
169 ; CHECKIF-NEXT: fmv.s fa0, fa1
170 ; CHECKIF-NEXT: .LBB6_2: # %cond.end
173 br i1 %cnd, label %cond.end, label %cond.false
175 cond.false: ; preds = %entry
178 cond.end: ; preds = %entry, %cond.false
179 %cond = phi float [ %b, %cond.false ], [ %a, %entry ]