xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/Fast-ISel/icmpa.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=pic -O0 -fast-isel-abort=1 -mcpu=mips32r2 \
2*9880d681SAndroid Build Coastguard Worker; RUN:     < %s | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=pic -O0 -fast-isel-abort=1 -mcpu=mips32 \
4*9880d681SAndroid Build Coastguard Worker; RUN:     < %s | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker@c = global i32 4, align 4
7*9880d681SAndroid Build Coastguard Worker@d = global i32 9, align 4
8*9880d681SAndroid Build Coastguard Worker@uc = global i32 4, align 4
9*9880d681SAndroid Build Coastguard Worker@ud = global i32 9, align 4
10*9880d681SAndroid Build Coastguard Worker@b1 = common global i32 0, align 4
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
13*9880d681SAndroid Build Coastguard Workerdefine void @eq()  {
14*9880d681SAndroid Build Coastguard Workerentry:
15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  eq
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
18*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
19*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %0, %1
20*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
21*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
22*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
23*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
24*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
25*9880d681SAndroid Build Coastguard Worker; CHECK:  xor  $[[REG1:[0-9]+]], $[[REG_C]], $[[REG_D]]
26*9880d681SAndroid Build Coastguard Worker; CHECK:  sltiu  $[[REG2:[0-9]+]], $[[REG1]], 1
27*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltiu can only produce 0 and 1.
28*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG2]], 1
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
31*9880d681SAndroid Build Coastguard Worker  ret void
32*9880d681SAndroid Build Coastguard Worker}
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
35*9880d681SAndroid Build Coastguard Workerdefine void @ne()  {
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  ne
38*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
39*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
40*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ne i32 %0, %1
41*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
42*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
43*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
44*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
45*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
46*9880d681SAndroid Build Coastguard Worker; CHECK:  xor  $[[REG1:[0-9]+]], $[[REG_C]], $[[REG_D]]
47*9880d681SAndroid Build Coastguard Worker; CHECK:  sltu  $[[REG2:[0-9]+]], $zero, $[[REG1]]
48*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltu can only produce 0 and 1.
49*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG2]], 1
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
52*9880d681SAndroid Build Coastguard Worker  ret void
53*9880d681SAndroid Build Coastguard Worker}
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
56*9880d681SAndroid Build Coastguard Workerdefine void @ugt()  {
57*9880d681SAndroid Build Coastguard Workerentry:
58*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  ugt
59*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @uc, align 4
60*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @ud, align 4
61*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ugt i32 %0, %1
62*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
63*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD_GOT:[0-9+]]], %got(ud)(${{[0-9]+}})
64*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC_GOT:[0-9+]]], %got(uc)(${{[0-9]+}})
65*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD:[0-9]+]], 0($[[REG_UD_GOT]])
66*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC:[0-9]+]], 0($[[REG_UC_GOT]])
67*9880d681SAndroid Build Coastguard Worker; CHECK:  sltu  $[[REG1:[0-9]+]], $[[REG_UD]], $[[REG_UC]]
68*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltu can only produce 0 and 1.
69*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG1]], 1
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
72*9880d681SAndroid Build Coastguard Worker  ret void
73*9880d681SAndroid Build Coastguard Worker}
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
76*9880d681SAndroid Build Coastguard Workerdefine void @ult()  {
77*9880d681SAndroid Build Coastguard Workerentry:
78*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  ult
79*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @uc, align 4
80*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @ud, align 4
81*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ult i32 %0, %1
82*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
83*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD_GOT:[0-9+]]], %got(ud)(${{[0-9]+}})
84*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC_GOT:[0-9+]]], %got(uc)(${{[0-9]+}})
85*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD:[0-9]+]], 0($[[REG_UD_GOT]])
86*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC:[0-9]+]], 0($[[REG_UC_GOT]])
87*9880d681SAndroid Build Coastguard Worker; CHECK:  sltu  $[[REG1:[0-9]+]], $[[REG_UC]], $[[REG_UD]]
88*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltu can only produce 0 and 1.
89*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG1]], 1
90*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
91*9880d681SAndroid Build Coastguard Worker  ret void
92*9880d681SAndroid Build Coastguard Worker}
93*9880d681SAndroid Build Coastguard Worker
94*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
95*9880d681SAndroid Build Coastguard Workerdefine void @uge()  {
96*9880d681SAndroid Build Coastguard Workerentry:
97*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  uge
98*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @uc, align 4
99*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @ud, align 4
100*9880d681SAndroid Build Coastguard Worker  %cmp = icmp uge i32 %0, %1
101*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
102*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD_GOT:[0-9+]]], %got(ud)(${{[0-9]+}})
103*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC_GOT:[0-9+]]], %got(uc)(${{[0-9]+}})
104*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD:[0-9]+]], 0($[[REG_UD_GOT]])
105*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC:[0-9]+]], 0($[[REG_UC_GOT]])
106*9880d681SAndroid Build Coastguard Worker; CHECK:  sltu  $[[REG1:[0-9]+]], $[[REG_UC]], $[[REG_UD]]
107*9880d681SAndroid Build Coastguard Worker; CHECK:  xori  $[[REG2:[0-9]+]], $[[REG1]], 1
108*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltu can only produce 0 and 1.
109*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG2]], 1
110*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
111*9880d681SAndroid Build Coastguard Worker  ret void
112*9880d681SAndroid Build Coastguard Worker}
113*9880d681SAndroid Build Coastguard Worker
114*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
115*9880d681SAndroid Build Coastguard Workerdefine void @ule()  {
116*9880d681SAndroid Build Coastguard Workerentry:
117*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent  ule
118*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @uc, align 4
119*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @ud, align 4
120*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ule i32 %0, %1
121*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
122*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD_GOT:[0-9+]]], %got(ud)(${{[0-9]+}})
123*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC_GOT:[0-9+]]], %got(uc)(${{[0-9]+}})
124*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UD:[0-9]+]], 0($[[REG_UD_GOT]])
125*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_UC:[0-9]+]], 0($[[REG_UC_GOT]])
126*9880d681SAndroid Build Coastguard Worker; CHECK:  sltu  $[[REG1:[0-9]+]], $[[REG_UD]], $[[REG_UC]]
127*9880d681SAndroid Build Coastguard Worker; CHECK:  xori  $[[REG2:[0-9]+]], $[[REG1]], 1
128*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The sltu can only produce 0 and 1.
129*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG2]], 1
130*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
131*9880d681SAndroid Build Coastguard Worker  ret void
132*9880d681SAndroid Build Coastguard Worker}
133*9880d681SAndroid Build Coastguard Worker
134*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
135*9880d681SAndroid Build Coastguard Workerdefine void @sgt()  {
136*9880d681SAndroid Build Coastguard Workerentry:
137*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent sgt
138*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
139*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
140*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sgt i32 %0, %1
141*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
142*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
143*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
144*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
145*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
146*9880d681SAndroid Build Coastguard Worker; CHECK:  slt  $[[REG1:[0-9]+]], $[[REG_D]], $[[REG_C]]
147*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The slt can only produce 0 and 1.
148*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG1]], 1
149*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
150*9880d681SAndroid Build Coastguard Worker  ret void
151*9880d681SAndroid Build Coastguard Worker}
152*9880d681SAndroid Build Coastguard Worker
153*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
154*9880d681SAndroid Build Coastguard Workerdefine void @slt()  {
155*9880d681SAndroid Build Coastguard Workerentry:
156*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent slt
157*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
158*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
159*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i32 %0, %1
160*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
161*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
162*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
163*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
164*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
165*9880d681SAndroid Build Coastguard Worker; CHECK:  slt  $[[REG1:[0-9]+]], $[[REG_C]], $[[REG_D]]
166*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The slt can only produce 0 and 1.
167*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG1]], 1
168*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
169*9880d681SAndroid Build Coastguard Worker  ret void
170*9880d681SAndroid Build Coastguard Worker}
171*9880d681SAndroid Build Coastguard Worker
172*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
173*9880d681SAndroid Build Coastguard Workerdefine void @sge()  {
174*9880d681SAndroid Build Coastguard Workerentry:
175*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent sge
176*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
177*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
178*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sge i32 %0, %1
179*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
180*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
181*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
182*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
183*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
184*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
185*9880d681SAndroid Build Coastguard Worker; CHECK:  slt  $[[REG1:[0-9]+]], $[[REG_C]], $[[REG_D]]
186*9880d681SAndroid Build Coastguard Worker; CHECK:  xori  $[[REG2:[0-9]+]], $[[REG1]], 1
187*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The slt can only produce 0 and 1.
188*9880d681SAndroid Build Coastguard Worker; CHECK:  andi  ${{[0-9]+}}, $[[REG2]], 1
189*9880d681SAndroid Build Coastguard Worker  ret void
190*9880d681SAndroid Build Coastguard Worker}
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
193*9880d681SAndroid Build Coastguard Workerdefine void @sle()  {
194*9880d681SAndroid Build Coastguard Workerentry:
195*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:  .ent sle
196*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @c, align 4
197*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @d, align 4
198*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sle i32 %0, %1
199*9880d681SAndroid Build Coastguard Worker  %conv = zext i1 %cmp to i32
200*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D_GOT:[0-9+]]], %got(d)(${{[0-9]+}})
201*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C_GOT:[0-9+]]], %got(c)(${{[0-9]+}})
202*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_D:[0-9]+]], 0($[[REG_D_GOT]])
203*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:  lw	$[[REG_C:[0-9]+]], 0($[[REG_C_GOT]])
204*9880d681SAndroid Build Coastguard Worker; CHECK:        slt     $[[REG1:[0-9]+]], $[[REG_D]], $[[REG_C]]
205*9880d681SAndroid Build Coastguard Worker; CHECK:        xori    $[[REG2:[0-9]+]], $[[REG1]], 1
206*9880d681SAndroid Build Coastguard Worker; FIXME: This instruction is redundant. The slt can only produce 0 and 1.
207*9880d681SAndroid Build Coastguard Worker; CHECK:        andi    ${{[0-9]+}}, $[[REG2]], 1
208*9880d681SAndroid Build Coastguard Worker  store i32 %conv, i32* @b1, align 4
209*9880d681SAndroid Build Coastguard Worker  ret void
210*9880d681SAndroid Build Coastguard Worker}
211