Skip to content

Commit

Permalink
[X86] Add non-uniform vector tests for 'one bit diff' comparison fold
Browse files Browse the repository at this point in the history
  • Loading branch information
RKSimon committed May 26, 2022
1 parent a9a0120 commit b45e046
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions llvm/test/CodeGen/X86/setcc-logic.ll
Expand Up @@ -523,6 +523,21 @@ define i1 @or_icmps_const_1bit_diff(i8 %x) {
ret i1 %r
}

define <4 x i32> @or_icmps_const_1bit_diff_vec(<4 x i32> %x) {
; CHECK-LABEL: or_icmps_const_1bit_diff_vec:
; CHECK: # %bb.0:
; CHECK-NEXT: movdqa {{.*#+}} xmm1 = [43,45,43,45]
; CHECK-NEXT: pcmpeqd %xmm0, %xmm1
; CHECK-NEXT: pcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
; CHECK-NEXT: por %xmm1, %xmm0
; CHECK-NEXT: retq
%a = icmp eq <4 x i32> %x, <i32 43, i32 45, i32 43, i32 45>
%b = icmp eq <4 x i32> %x, <i32 45, i32 43, i32 45, i32 43>
%t = or <4 x i1> %a, %b
%r = sext <4 x i1> %t to <4 x i32>
ret <4 x i32> %r
}

define i1 @and_icmps_const_1bit_diff(i32 %x) {
; CHECK-LABEL: and_icmps_const_1bit_diff:
; CHECK: # %bb.0:
Expand All @@ -536,6 +551,24 @@ define i1 @and_icmps_const_1bit_diff(i32 %x) {
ret i1 %r
}

define <4 x i32> @and_icmps_const_1bit_diff_vec(<4 x i32> %x) {
; CHECK-LABEL: and_icmps_const_1bit_diff_vec:
; CHECK: # %bb.0:
; CHECK-NEXT: movdqa {{.*#+}} xmm1 = [44,60,44,60]
; CHECK-NEXT: pcmpeqd %xmm0, %xmm1
; CHECK-NEXT: pcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
; CHECK-NEXT: pcmpeqd %xmm2, %xmm2
; CHECK-NEXT: pxor %xmm0, %xmm2
; CHECK-NEXT: pandn %xmm2, %xmm1
; CHECK-NEXT: movdqa %xmm1, %xmm0
; CHECK-NEXT: retq
%a = icmp ne <4 x i32> %x, <i32 44, i32 60, i32 44, i32 60>
%b = icmp ne <4 x i32> %x, <i32 60, i32 44, i32 60, i32 44>
%t = and <4 x i1> %a, %b
%r = sext <4 x i1> %t to <4 x i32>
ret <4 x i32> %r
}

; Negative test - extra use prevents optimization

define i1 @or_icmps_const_1bit_diff_extra_use(i8 %x, i8* %p) {
Expand Down

0 comments on commit b45e046

Please sign in to comment.