@@ -136,6 +136,51 @@ define i64 @andn64(i64 %x, i64 %y) {
136
136
ret i64 %tmp2
137
137
}
138
138
139
+ ; FIXME: Don't choose a 'test' if an 'andn' can be used.
140
+ define i1 @andn_cmp (i32 %x , i32 %y ) {
141
+ ; CHECK-LABEL: andn_cmp:
142
+ ; CHECK: # BB#0:
143
+ ; CHECK-NEXT: notl %edi
144
+ ; CHECK-NEXT: testl %esi, %edi
145
+ ; CHECK-NEXT: sete %al
146
+ ; CHECK-NEXT: retq
147
+ ;
148
+ %notx = xor i32 %x , -1
149
+ %and = and i32 %notx , %y
150
+ %cmp = icmp eq i32 %and , 0
151
+ ret i1 %cmp
152
+ }
153
+
154
+ ; FIXME: Don't choose a 'test' if an 'andn' can be used.
155
+ define i1 @andn_cmp_swap_ops (i64 %x , i64 %y ) {
156
+ ; CHECK-LABEL: andn_cmp_swap_ops:
157
+ ; CHECK: # BB#0:
158
+ ; CHECK-NEXT: notq %rdi
159
+ ; CHECK-NEXT: testq %rdi, %rsi
160
+ ; CHECK-NEXT: sete %al
161
+ ; CHECK-NEXT: retq
162
+ ;
163
+ %notx = xor i64 %x , -1
164
+ %and = and i64 %y , %notx
165
+ %cmp = icmp eq i64 %and , 0
166
+ ret i1 %cmp
167
+ }
168
+
169
+ ; Use a 'test' (not an 'and') because 'andn' only works for i32/i64.
170
+ define i1 @andn_cmp_i8 (i8 %x , i8 %y ) {
171
+ ; CHECK-LABEL: andn_cmp_i8:
172
+ ; CHECK: # BB#0:
173
+ ; CHECK-NEXT: notb %sil
174
+ ; CHECK-NEXT: testb %sil, %dil
175
+ ; CHECK-NEXT: sete %al
176
+ ; CHECK-NEXT: retq
177
+ ;
178
+ %noty = xor i8 %y , -1
179
+ %and = and i8 %x , %noty
180
+ %cmp = icmp eq i8 %and , 0
181
+ ret i1 %cmp
182
+ }
183
+
139
184
define i32 @bextr32 (i32 %x , i32 %y ) {
140
185
; CHECK-LABEL: bextr32:
141
186
; CHECK: # BB#0:
0 commit comments