1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s --check-prefix=LA64
5 ;; Exercise the bare integers 'select' LLVM IR: https://llvm.org/docs/LangRef.html#select-instruction
7 define i1 @bare_select_i1(i1 %a, i1 %b, i1 %c) {
8 ; LA32-LABEL: bare_select_i1:
10 ; LA32-NEXT: andi $a0, $a0, 1
11 ; LA32-NEXT: masknez $a2, $a2, $a0
12 ; LA32-NEXT: maskeqz $a0, $a1, $a0
13 ; LA32-NEXT: or $a0, $a0, $a2
16 ; LA64-LABEL: bare_select_i1:
18 ; LA64-NEXT: andi $a0, $a0, 1
19 ; LA64-NEXT: masknez $a2, $a2, $a0
20 ; LA64-NEXT: maskeqz $a0, $a1, $a0
21 ; LA64-NEXT: or $a0, $a0, $a2
23 %res = select i1 %a, i1 %b, i1 %c
27 define i8 @bare_select_i8(i1 %a, i8 %b, i8 %c) {
28 ; LA32-LABEL: bare_select_i8:
30 ; LA32-NEXT: andi $a0, $a0, 1
31 ; LA32-NEXT: masknez $a2, $a2, $a0
32 ; LA32-NEXT: maskeqz $a0, $a1, $a0
33 ; LA32-NEXT: or $a0, $a0, $a2
36 ; LA64-LABEL: bare_select_i8:
38 ; LA64-NEXT: andi $a0, $a0, 1
39 ; LA64-NEXT: masknez $a2, $a2, $a0
40 ; LA64-NEXT: maskeqz $a0, $a1, $a0
41 ; LA64-NEXT: or $a0, $a0, $a2
43 %res = select i1 %a, i8 %b, i8 %c
47 define i16 @bare_select_i16(i1 %a, i16 %b, i16 %c) {
48 ; LA32-LABEL: bare_select_i16:
50 ; LA32-NEXT: andi $a0, $a0, 1
51 ; LA32-NEXT: masknez $a2, $a2, $a0
52 ; LA32-NEXT: maskeqz $a0, $a1, $a0
53 ; LA32-NEXT: or $a0, $a0, $a2
56 ; LA64-LABEL: bare_select_i16:
58 ; LA64-NEXT: andi $a0, $a0, 1
59 ; LA64-NEXT: masknez $a2, $a2, $a0
60 ; LA64-NEXT: maskeqz $a0, $a1, $a0
61 ; LA64-NEXT: or $a0, $a0, $a2
63 %res = select i1 %a, i16 %b, i16 %c
67 define i32 @bare_select_i32(i1 %a, i32 %b, i32 %c) {
68 ; LA32-LABEL: bare_select_i32:
70 ; LA32-NEXT: andi $a0, $a0, 1
71 ; LA32-NEXT: masknez $a2, $a2, $a0
72 ; LA32-NEXT: maskeqz $a0, $a1, $a0
73 ; LA32-NEXT: or $a0, $a0, $a2
76 ; LA64-LABEL: bare_select_i32:
78 ; LA64-NEXT: andi $a0, $a0, 1
79 ; LA64-NEXT: masknez $a2, $a2, $a0
80 ; LA64-NEXT: maskeqz $a0, $a1, $a0
81 ; LA64-NEXT: or $a0, $a0, $a2
83 %res = select i1 %a, i32 %b, i32 %c
87 define i64 @bare_select_i64(i1 %a, i64 %b, i64 %c) {
88 ; LA32-LABEL: bare_select_i64:
90 ; LA32-NEXT: andi $a5, $a0, 1
91 ; LA32-NEXT: masknez $a0, $a3, $a5
92 ; LA32-NEXT: maskeqz $a1, $a1, $a5
93 ; LA32-NEXT: or $a0, $a1, $a0
94 ; LA32-NEXT: masknez $a1, $a4, $a5
95 ; LA32-NEXT: maskeqz $a2, $a2, $a5
96 ; LA32-NEXT: or $a1, $a2, $a1
99 ; LA64-LABEL: bare_select_i64:
101 ; LA64-NEXT: andi $a0, $a0, 1
102 ; LA64-NEXT: masknez $a2, $a2, $a0
103 ; LA64-NEXT: maskeqz $a0, $a1, $a0
104 ; LA64-NEXT: or $a0, $a0, $a2
106 %res = select i1 %a, i64 %b, i64 %c
110 define i16 @bare_select_zero_i16(i1 %a, i16 %b) {
111 ; LA32-LABEL: bare_select_zero_i16:
113 ; LA32-NEXT: andi $a0, $a0, 1
114 ; LA32-NEXT: masknez $a0, $a1, $a0
117 ; LA64-LABEL: bare_select_zero_i16:
119 ; LA64-NEXT: andi $a0, $a0, 1
120 ; LA64-NEXT: masknez $a0, $a1, $a0
122 %res = select i1 %a, i16 0, i16 %b
126 define i32 @bare_select_zero_i32(i1 %a, i32 %b) {
127 ; LA32-LABEL: bare_select_zero_i32:
129 ; LA32-NEXT: andi $a0, $a0, 1
130 ; LA32-NEXT: maskeqz $a0, $a1, $a0
133 ; LA64-LABEL: bare_select_zero_i32:
135 ; LA64-NEXT: andi $a0, $a0, 1
136 ; LA64-NEXT: maskeqz $a0, $a1, $a0
138 %res = select i1 %a, i32 %b, i32 0