<commit_before>; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefix=SSE
; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s --check-prefix=AVX

; xor undef, undef --> 0 because it's not worth fighting to make that return undef?

define <4 x i64> @xor_insert_insert(<2 x i64> %x, <2 x i64> %y) {
; SSE-LABEL: xor_insert_insert:
; SSE:       # %bb.0:
; SSE-NEXT:    xorps %xmm1, %xmm0
; SSE-NEXT:    xorps %xmm1, %xmm1
; SSE-NEXT:    retq
;
; AVX-LABEL: xor_insert_insert:
; AVX:       # %bb.0:
; AVX-NEXT:    vxorps %xmm1, %xmm0, %xmm0
; AVX-NEXT:    retq
  %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %r = xor <4 x i64> %xw, %yw
  ret <4 x i64> %r
}

define <4 x i64> @xor_insert_insert_high_half(<2 x i64> %x, <2 x i64> %y) {
; SSE-LABEL: xor_insert_insert_high_half:
; SSE:       # %bb.0:
; SSE-NEXT:    xorps %xmm0, %xmm1
; SSE-NEXT:    xorps %xmm0, %xmm0
; SSE-NEXT:    retq
;
; AVX-LABEL: xor_insert_insert_high_half:
; AVX:       # %bb.0:
; AVX-NEXT:    vxorps %xmm1, %xmm0, %xmm0
; AVX-NEXT:    vxorps %xmm1, %xmm1, %xmm1
; AVX-NEXT:    vinsertf128 $1, %xmm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
  %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
  %r = xor <4 x i64> %xw, %yw
  ret <4 x i64> %r
}

; All elements of the add are undefined:
;  x[0] , x[1] , x[2] , x[3],  u ,   u  ,   u  ,  u
; +  u  ,   u  ,   u  ,   u , 42 ,  43  ,  44  , 45

define <8 x i32> @add_undef_elts(<4 x i32> %x) {
; SSE-LABEL: add_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    retq
;
; AVX-LABEL: add_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vpaddd {{.*}}(%rip), %ymm0, %ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = [6,0,5,4,3,2,1,7]
; AVX-NEXT:    vpermd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
  %bogus_bo = add <8 x i32> %extend, <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>
  %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 6, i32 0, i32 5, i32 4, i32 3, i32 2, i32 1, i32 7>
  ret <8 x i32> %arbitrary_shuf
}

; Verify that constant operand 0 for a sub works too.

define <8 x i32> @sub_undef_elts(<4 x i32> %x) {
; SSE-LABEL: sub_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    retq
;
; AVX-LABEL: sub_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = <u,u,u,u,42,43,44,12>
; AVX-NEXT:    vpsubd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = [1,0,5,4,3,2,6,7]
; AVX-NEXT:    vpermd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
  %bogus_bo = sub <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>, %extend
  %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 1, i32 0, i32 5, i32 4, i32 3, i32 2, i32 6, i32 7>
  ret <8 x i32> %arbitrary_shuf
}

; Verify that different types work.

define <4 x i64> @or_undef_elts(<2 x i64> %x) {
; SSE-LABEL: or_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    pcmpeqd %xmm0, %xmm0
; SSE-NEXT:    pcmpeqd %xmm1, %xmm1
; SSE-NEXT:    retq
;
; AVX-LABEL: or_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vorps {{.*}}(%rip), %ymm0, %ymm0
; AVX-NEXT:    vpermpd {{.*#+}} ymm0 = ymm0[3,0,1,2]
; AVX-NEXT:    retq
  %extend = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %bogus_bo = or <4 x i64> %extend, <i64 undef, i64 undef, i64 42, i64 43>
  %arbitrary_shuf = shufflevector <4 x i64> %bogus_bo, <4 x i64> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
  ret <4 x i64> %arbitrary_shuf
}

; Verify that this isn't limited to high/low halves.

define <8 x i32> @xor_undef_elts(<4 x i32> %x) {
; SSE-LABEL: xor_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    pshufd {{.*#+}} xmm1 = xmm0[0,1,1,3]
; SSE-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[0,2,2,3]
; SSE-NEXT:    pxor {{.*}}(%rip), %xmm2
; SSE-NEXT:    pxor {{.*}}(%rip), %xmm1
; SSE-NEXT:    movdqa %xmm1, %xmm0
; SSE-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],xmm2[2,0]<commit_msg>[x86] add partial undef 'and' test; NFC<commit_after>; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefix=SSE
; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s --check-prefix=AVX

; xor undef, undef --> 0 because it's not worth fighting to make that return undef?

define <4 x i64> @xor_insert_insert(<2 x i64> %x, <2 x i64> %y) {
; SSE-LABEL: xor_insert_insert:
; SSE:       # %bb.0:
; SSE-NEXT:    xorps %xmm1, %xmm0
; SSE-NEXT:    xorps %xmm1, %xmm1
; SSE-NEXT:    retq
;
; AVX-LABEL: xor_insert_insert:
; AVX:       # %bb.0:
; AVX-NEXT:    vxorps %xmm1, %xmm0, %xmm0
; AVX-NEXT:    retq
  %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %r = xor <4 x i64> %xw, %yw
  ret <4 x i64> %r
}

define <4 x i64> @xor_insert_insert_high_half(<2 x i64> %x, <2 x i64> %y) {
; SSE-LABEL: xor_insert_insert_high_half:
; SSE:       # %bb.0:
; SSE-NEXT:    xorps %xmm0, %xmm1
; SSE-NEXT:    xorps %xmm0, %xmm0
; SSE-NEXT:    retq
;
; AVX-LABEL: xor_insert_insert_high_half:
; AVX:       # %bb.0:
; AVX-NEXT:    vxorps %xmm1, %xmm0, %xmm0
; AVX-NEXT:    vxorps %xmm1, %xmm1, %xmm1
; AVX-NEXT:    vinsertf128 $1, %xmm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
  %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
  %r = xor <4 x i64> %xw, %yw
  ret <4 x i64> %r
}

; All elements of the add are undefined:
;  x[0] , x[1] , x[2] , x[3],  u ,   u  ,   u  ,  u
; +  u  ,   u  ,   u  ,   u , 42 ,  43  ,  44  , 45

define <8 x i32> @add_undef_elts(<4 x i32> %x) {
; SSE-LABEL: add_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    retq
;
; AVX-LABEL: add_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vpaddd {{.*}}(%rip), %ymm0, %ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = [6,0,5,4,3,2,1,7]
; AVX-NEXT:    vpermd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
  %bogus_bo = add <8 x i32> %extend, <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>
  %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 6, i32 0, i32 5, i32 4, i32 3, i32 2, i32 1, i32 7>
  ret <8 x i32> %arbitrary_shuf
}

; Verify that constant operand 0 for a sub works too.

define <8 x i32> @sub_undef_elts(<4 x i32> %x) {
; SSE-LABEL: sub_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    retq
;
; AVX-LABEL: sub_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = <u,u,u,u,42,43,44,12>
; AVX-NEXT:    vpsubd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    vmovdqa {{.*#+}} ymm1 = [1,0,5,4,3,2,6,7]
; AVX-NEXT:    vpermd %ymm0, %ymm1, %ymm0
; AVX-NEXT:    retq
  %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
  %bogus_bo = sub <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>, %extend
  %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 1, i32 0, i32 5, i32 4, i32 3, i32 2, i32 6, i32 7>
  ret <8 x i32> %arbitrary_shuf
}

; and undef, C --> 0, so this tests that we are tracking known zero lanes.

define <4 x i64> @and_undef_elts(<2 x i64> %x) {
; SSE-LABEL: and_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    xorps %xmm0, %xmm0
; SSE-NEXT:    xorps %xmm1, %xmm1
; SSE-NEXT:    retq
;
; AVX-LABEL: and_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vandps {{.*}}(%rip), %ymm0, %ymm0
; AVX-NEXT:    vpermpd {{.*#+}} ymm0 = ymm0[3,0,1,2]
; AVX-NEXT:    retq
  %extend = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %bogus_bo = and <4 x i64> %extend, <i64 undef, i64 undef, i64 42, i64 43>
  %arbitrary_shuf = shufflevector <4 x i64> %bogus_bo, <4 x i64> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
  ret <4 x i64> %arbitrary_shuf
}

; or undef, C --> -1, so this tests that we are tracking known all-ones lanes.

define <4 x i64> @or_undef_elts(<2 x i64> %x) {
; SSE-LABEL: or_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    pcmpeqd %xmm0, %xmm0
; SSE-NEXT:    pcmpeqd %xmm1, %xmm1
; SSE-NEXT:    retq
;
; AVX-LABEL: or_undef_elts:
; AVX:       # %bb.0:
; AVX-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; AVX-NEXT:    vorps {{.*}}(%rip), %ymm0, %ymm0
; AVX-NEXT:    vpermpd {{.*#+}} ymm0 = ymm0[3,0,1,2]
; AVX-NEXT:    retq
  %extend = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
  %bogus_bo = or <4 x i64> %extend, <i64 undef, i64 undef, i64 42, i64 43>
  %arbitrary_shuf = shufflevector <4 x i64> %bogus_bo, <4 x i64> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
  ret <4 x i64> %arbitrary_shuf
}

; Verify that this isn't limited to high/low halves.

define <8 x i32> @xor_undef_elts(<4 x i32> %x) {
; SSE-LABEL: xor_undef_elts:
; SSE:       # %bb.0:
; SSE-NEXT:    pshufd {{.*#+}} xmm1 = xmm0[0,1,1,3]
; SSE-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[0,2,2,3]
; SSE-NEXT:    pxor {{.*}}(%rip), %xmm2
; SSE-NEXT:    pxor {{.*}}(%rip), %xmm1
; SSE-NEXT:    movdqa %xmm1, %xmm0
; SSE-NEXT:    shufps {{.*#+}} xmm0 = xmm0[1,0],xmm2[2,0]
{'fraction_non_alphanumeric': 0.1801463508569228, 'fraction_numerical': 0.10697092239553245, 'mean_word_length': 3.0510920436817472, 'pattern_counts': {'":': 0, '<': 156, '<?xml version=': 0, '>': 156, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2753105', 'n_tokens_mistral': 5813, 'n_tokens_neox': 5141, 'n_words': 1488}