Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit c2571ee

Browse files
committed
[x86] show missed opportunities to use andn
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265850 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5451c70 commit c2571ee

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/CodeGen/X86/bmi.ll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,51 @@ define i64 @andn64(i64 %x, i64 %y) {
136136
ret i64 %tmp2
137137
}
138138

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+
139184
define i32 @bextr32(i32 %x, i32 %y) {
140185
; CHECK-LABEL: bextr32:
141186
; CHECK: # BB#0:

0 commit comments

Comments
 (0)