1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 --mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; Test double-precision floating-point values selection after integers comparison
7 define double @select_eq(i32 signext %a, i32 signext %b, double %x, double %y) {
8 ; LA32-LABEL: select_eq:
10 ; LA32-NEXT: xor $a0, $a0, $a1
11 ; LA32-NEXT: sltui $a0, $a0, 1
12 ; LA32-NEXT: movgr2cf $fcc0, $a0
13 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
16 ; LA64-LABEL: select_eq:
18 ; LA64-NEXT: xor $a0, $a0, $a1
19 ; LA64-NEXT: sltui $a0, $a0, 1
20 ; LA64-NEXT: movgr2cf $fcc0, $a0
21 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
23 %cond = icmp eq i32 %a, %b
24 %res = select i1 %cond, double %x, double %y
28 define double @select_ne(i32 signext %a, i32 signext %b, double %x, double %y) {
29 ; LA32-LABEL: select_ne:
31 ; LA32-NEXT: xor $a0, $a0, $a1
32 ; LA32-NEXT: sltu $a0, $zero, $a0
33 ; LA32-NEXT: movgr2cf $fcc0, $a0
34 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
37 ; LA64-LABEL: select_ne:
39 ; LA64-NEXT: xor $a0, $a0, $a1
40 ; LA64-NEXT: sltu $a0, $zero, $a0
41 ; LA64-NEXT: movgr2cf $fcc0, $a0
42 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
44 %cond = icmp ne i32 %a, %b
45 %res = select i1 %cond, double %x, double %y
49 define double @select_ugt(i32 signext %a, i32 signext %b, double %x, double %y) {
50 ; LA32-LABEL: select_ugt:
52 ; LA32-NEXT: sltu $a0, $a1, $a0
53 ; LA32-NEXT: movgr2cf $fcc0, $a0
54 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
57 ; LA64-LABEL: select_ugt:
59 ; LA64-NEXT: sltu $a0, $a1, $a0
60 ; LA64-NEXT: movgr2cf $fcc0, $a0
61 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
63 %cond = icmp ugt i32 %a, %b
64 %res = select i1 %cond, double %x, double %y
68 define double @select_uge(i32 signext %a, i32 signext %b, double %x, double %y) {
69 ; LA32-LABEL: select_uge:
71 ; LA32-NEXT: sltu $a0, $a0, $a1
72 ; LA32-NEXT: xori $a0, $a0, 1
73 ; LA32-NEXT: movgr2cf $fcc0, $a0
74 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
77 ; LA64-LABEL: select_uge:
79 ; LA64-NEXT: sltu $a0, $a0, $a1
80 ; LA64-NEXT: xori $a0, $a0, 1
81 ; LA64-NEXT: movgr2cf $fcc0, $a0
82 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
84 %cond = icmp uge i32 %a, %b
85 %res = select i1 %cond, double %x, double %y
89 define double @select_ult(i32 signext %a, i32 signext %b, double %x, double %y) {
90 ; LA32-LABEL: select_ult:
92 ; LA32-NEXT: sltu $a0, $a0, $a1
93 ; LA32-NEXT: movgr2cf $fcc0, $a0
94 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
97 ; LA64-LABEL: select_ult:
99 ; LA64-NEXT: sltu $a0, $a0, $a1
100 ; LA64-NEXT: movgr2cf $fcc0, $a0
101 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
103 %cond = icmp ult i32 %a, %b
104 %res = select i1 %cond, double %x, double %y
108 define double @select_ule(i32 signext %a, i32 signext %b, double %x, double %y) {
109 ; LA32-LABEL: select_ule:
111 ; LA32-NEXT: sltu $a0, $a1, $a0
112 ; LA32-NEXT: xori $a0, $a0, 1
113 ; LA32-NEXT: movgr2cf $fcc0, $a0
114 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
117 ; LA64-LABEL: select_ule:
119 ; LA64-NEXT: sltu $a0, $a1, $a0
120 ; LA64-NEXT: xori $a0, $a0, 1
121 ; LA64-NEXT: movgr2cf $fcc0, $a0
122 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
124 %cond = icmp ule i32 %a, %b
125 %res = select i1 %cond, double %x, double %y
129 define double @select_sgt(i32 signext %a, i32 signext %b, double %x, double %y) {
130 ; LA32-LABEL: select_sgt:
132 ; LA32-NEXT: slt $a0, $a1, $a0
133 ; LA32-NEXT: movgr2cf $fcc0, $a0
134 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
137 ; LA64-LABEL: select_sgt:
139 ; LA64-NEXT: slt $a0, $a1, $a0
140 ; LA64-NEXT: movgr2cf $fcc0, $a0
141 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
143 %cond = icmp sgt i32 %a, %b
144 %res = select i1 %cond, double %x, double %y
148 define double @select_sge(i32 signext %a, i32 signext %b, double %x, double %y) {
149 ; LA32-LABEL: select_sge:
151 ; LA32-NEXT: slt $a0, $a0, $a1
152 ; LA32-NEXT: xori $a0, $a0, 1
153 ; LA32-NEXT: movgr2cf $fcc0, $a0
154 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
157 ; LA64-LABEL: select_sge:
159 ; LA64-NEXT: slt $a0, $a0, $a1
160 ; LA64-NEXT: xori $a0, $a0, 1
161 ; LA64-NEXT: movgr2cf $fcc0, $a0
162 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
164 %cond = icmp sge i32 %a, %b
165 %res = select i1 %cond, double %x, double %y
169 define double @select_slt(i32 signext %a, i32 signext %b, double %x, double %y) {
170 ; LA32-LABEL: select_slt:
172 ; LA32-NEXT: slt $a0, $a0, $a1
173 ; LA32-NEXT: movgr2cf $fcc0, $a0
174 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
177 ; LA64-LABEL: select_slt:
179 ; LA64-NEXT: slt $a0, $a0, $a1
180 ; LA64-NEXT: movgr2cf $fcc0, $a0
181 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
183 %cond = icmp slt i32 %a, %b
184 %res = select i1 %cond, double %x, double %y
188 define double @select_sle(i32 signext %a, i32 signext %b, double %x, double %y) {
189 ; LA32-LABEL: select_sle:
191 ; LA32-NEXT: slt $a0, $a1, $a0
192 ; LA32-NEXT: xori $a0, $a0, 1
193 ; LA32-NEXT: movgr2cf $fcc0, $a0
194 ; LA32-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
197 ; LA64-LABEL: select_sle:
199 ; LA64-NEXT: slt $a0, $a1, $a0
200 ; LA64-NEXT: xori $a0, $a0, 1
201 ; LA64-NEXT: movgr2cf $fcc0, $a0
202 ; LA64-NEXT: fsel $fa0, $fa1, $fa0, $fcc0
204 %cond = icmp sle i32 %a, %b
205 %res = select i1 %cond, double %x, double %y