1; RUN: llc -march=mipsel < %s | FileCheck %s
2
3@g1 = external global i32
4
5; CHECK-LABEL: seteq0:
6; CHECK: sltiu ${{[0-9]+}}, $4, 1
7
8define i32 @seteq0(i32 %a) {
9entry:
10  %cmp = icmp eq i32 %a, 0
11  %conv = zext i1 %cmp to i32
12  ret i32 %conv
13}
14
15; CHECK-LABEL: setne0:
16; CHECK: sltu ${{[0-9]+}}, $zero, $4
17
18define i32 @setne0(i32 %a) {
19entry:
20  %cmp = icmp ne i32 %a, 0
21  %conv = zext i1 %cmp to i32
22  ret i32 %conv
23}
24
25; CHECK-LABEL: slti_beq0:
26; CHECK: slti $[[R0:[0-9]+]], $4, -32768
27; CHECK: beqz $[[R0]]
28
29define void @slti_beq0(i32 %a) {
30entry:
31  %cmp = icmp slt i32 %a, -32768
32  br i1 %cmp, label %if.then, label %if.end
33
34if.then:
35  store i32 %a, i32* @g1, align 4
36  br label %if.end
37
38if.end:
39  ret void
40}
41
42; CHECK-LABEL: slti_beq1:
43; CHECK: slt ${{[0-9]+}}
44
45define void @slti_beq1(i32 %a) {
46entry:
47  %cmp = icmp slt i32 %a, -32769
48  br i1 %cmp, label %if.then, label %if.end
49
50if.then:
51  store i32 %a, i32* @g1, align 4
52  br label %if.end
53
54if.end:
55  ret void
56}
57
58; CHECK-LABEL: slti_beq2:
59; CHECK: slti $[[R0:[0-9]+]], $4, 32767
60; CHECK: beqz $[[R0]]
61
62define void @slti_beq2(i32 %a) {
63entry:
64  %cmp = icmp slt i32 %a, 32767
65  br i1 %cmp, label %if.then, label %if.end
66
67if.then:
68  store i32 %a, i32* @g1, align 4
69  br label %if.end
70
71if.end:
72  ret void
73}
74
75; CHECK-LABEL: slti_beq3:
76; CHECK: slt ${{[0-9]+}}
77
78define void @slti_beq3(i32 %a) {
79entry:
80  %cmp = icmp slt i32 %a, 32768
81  br i1 %cmp, label %if.then, label %if.end
82
83if.then:
84  store i32 %a, i32* @g1, align 4
85  br label %if.end
86
87if.end:
88  ret void
89}
90
91; CHECK-LABEL: sltiu_beq0:
92; CHECK: sltiu $[[R0:[0-9]+]], $4, 32767
93; CHECK: beqz $[[R0]]
94
95define void @sltiu_beq0(i32 %a) {
96entry:
97  %cmp = icmp ult i32 %a, 32767
98  br i1 %cmp, label %if.then, label %if.end
99
100if.then:
101  store i32 %a, i32* @g1, align 4
102  br label %if.end
103
104if.end:
105  ret void
106}
107
108; CHECK-LABEL: sltiu_beq1:
109; CHECK: sltu ${{[0-9]+}}
110
111define void @sltiu_beq1(i32 %a) {
112entry:
113  %cmp = icmp ult i32 %a, 32768
114  br i1 %cmp, label %if.then, label %if.end
115
116if.then:
117  store i32 %a, i32* @g1, align 4
118  br label %if.end
119
120if.end:
121  ret void
122}
123
124; CHECK-LABEL: sltiu_beq2:
125; CHECK: sltiu $[[R0:[0-9]+]], $4, -32768
126; CHECK: beqz $[[R0]]
127
128define void @sltiu_beq2(i32 %a) {
129entry:
130  %cmp = icmp ult i32 %a, -32768
131  br i1 %cmp, label %if.then, label %if.end
132
133if.then:
134  store i32 %a, i32* @g1, align 4
135  br label %if.end
136
137if.end:
138  ret void
139}
140
141; CHECK-LABEL: sltiu_beq3:
142; CHECK: sltu ${{[0-9]+}}
143
144define void @sltiu_beq3(i32 %a) {
145entry:
146  %cmp = icmp ult i32 %a, -32769
147  br i1 %cmp, label %if.then, label %if.end
148
149if.then:
150  store i32 %a, i32* @g1, align 4
151  br label %if.end
152
153if.end:
154  ret void
155}
156