forked from OSchip/llvm-project
[x86] add tests for potential vector narrowing optimization (PR32790)
llvm-svn: 302910
This commit is contained in:
parent
cc7257c200
commit
ae362303fd
|
@ -0,0 +1,111 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE2
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX1
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX2
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX512 --check-prefix=AVX512F
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX512 --check-prefix=AVX512BW
|
||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512dq | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX512 --check-prefix=AVX512DQ
|
||||
|
||||
; AVX1 has support for 256-bit bitwise logic because the FP variants were included.
|
||||
; If using those ops requires extra insert/extract though, it's probably not worth it.
|
||||
|
||||
define <8 x i32> @PR32790(<8 x i32> %a, <8 x i32> %b, <8 x i32> %c, <8 x i32> %d) {
|
||||
; SSE-LABEL: PR32790:
|
||||
; SSE: # BB#0:
|
||||
; SSE-NEXT: paddd %xmm2, %xmm0
|
||||
; SSE-NEXT: paddd %xmm3, %xmm1
|
||||
; SSE-NEXT: pand %xmm5, %xmm1
|
||||
; SSE-NEXT: pand %xmm4, %xmm0
|
||||
; SSE-NEXT: psubd %xmm6, %xmm0
|
||||
; SSE-NEXT: psubd %xmm7, %xmm1
|
||||
; SSE-NEXT: retq
|
||||
;
|
||||
; AVX1-LABEL: PR32790:
|
||||
; AVX1: # BB#0:
|
||||
; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm4
|
||||
; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm5
|
||||
; AVX1-NEXT: vpaddd %xmm4, %xmm5, %xmm4
|
||||
; AVX1-NEXT: vpaddd %xmm1, %xmm0, %xmm0
|
||||
; AVX1-NEXT: vinsertf128 $1, %xmm4, %ymm0, %ymm0
|
||||
; AVX1-NEXT: vandps %ymm2, %ymm0, %ymm0
|
||||
; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
|
||||
; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm2
|
||||
; AVX1-NEXT: vpsubd %xmm2, %xmm1, %xmm1
|
||||
; AVX1-NEXT: vpsubd %xmm3, %xmm0, %xmm0
|
||||
; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
|
||||
; AVX1-NEXT: retq
|
||||
;
|
||||
; AVX2-LABEL: PR32790:
|
||||
; AVX2: # BB#0:
|
||||
; AVX2-NEXT: vpaddd %ymm1, %ymm0, %ymm0
|
||||
; AVX2-NEXT: vpand %ymm2, %ymm0, %ymm0
|
||||
; AVX2-NEXT: vpsubd %ymm3, %ymm0, %ymm0
|
||||
; AVX2-NEXT: retq
|
||||
;
|
||||
; AVX512-LABEL: PR32790:
|
||||
; AVX512: # BB#0:
|
||||
; AVX512-NEXT: vpaddd %ymm1, %ymm0, %ymm0
|
||||
; AVX512-NEXT: vpand %ymm2, %ymm0, %ymm0
|
||||
; AVX512-NEXT: vpsubd %ymm3, %ymm0, %ymm0
|
||||
; AVX512-NEXT: retq
|
||||
%add = add <8 x i32> %a, %b
|
||||
%and = and <8 x i32> %add, %c
|
||||
%sub = sub <8 x i32> %and, %d
|
||||
ret <8 x i32> %sub
|
||||
}
|
||||
|
||||
; In a more extreme case, even the later AVX targets should avoid extract/insert just
|
||||
; because 256-bit ops are supported.
|
||||
|
||||
define <4 x i32> @do_not_use_256bit_op(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i32> %d) {
|
||||
; SSE-LABEL: do_not_use_256bit_op:
|
||||
; SSE: # BB#0:
|
||||
; SSE-NEXT: pand %xmm3, %xmm1
|
||||
; SSE-NEXT: pand %xmm2, %xmm0
|
||||
; SSE-NEXT: psubd %xmm1, %xmm0
|
||||
; SSE-NEXT: retq
|
||||
;
|
||||
; AVX1-LABEL: do_not_use_256bit_op:
|
||||
; AVX1: # BB#0:
|
||||
; AVX1-NEXT: # kill: %XMM2<def> %XMM2<kill> %YMM2<def>
|
||||
; AVX1-NEXT: # kill: %XMM0<def> %XMM0<kill> %YMM0<def>
|
||||
; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
|
||||
; AVX1-NEXT: vinsertf128 $1, %xmm3, %ymm2, %ymm1
|
||||
; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
|
||||
; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
|
||||
; AVX1-NEXT: vpsubd %xmm1, %xmm0, %xmm0
|
||||
; AVX1-NEXT: vzeroupper
|
||||
; AVX1-NEXT: retq
|
||||
;
|
||||
; AVX2-LABEL: do_not_use_256bit_op:
|
||||
; AVX2: # BB#0:
|
||||
; AVX2-NEXT: # kill: %XMM2<def> %XMM2<kill> %YMM2<def>
|
||||
; AVX2-NEXT: # kill: %XMM0<def> %XMM0<kill> %YMM0<def>
|
||||
; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0
|
||||
; AVX2-NEXT: vinserti128 $1, %xmm3, %ymm2, %ymm1
|
||||
; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
|
||||
; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1
|
||||
; AVX2-NEXT: vpsubd %xmm1, %xmm0, %xmm0
|
||||
; AVX2-NEXT: vzeroupper
|
||||
; AVX2-NEXT: retq
|
||||
;
|
||||
; AVX512-LABEL: do_not_use_256bit_op:
|
||||
; AVX512: # BB#0:
|
||||
; AVX512-NEXT: # kill: %XMM2<def> %XMM2<kill> %YMM2<def>
|
||||
; AVX512-NEXT: # kill: %XMM0<def> %XMM0<kill> %YMM0<def>
|
||||
; AVX512-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0
|
||||
; AVX512-NEXT: vinserti128 $1, %xmm3, %ymm2, %ymm1
|
||||
; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
|
||||
; AVX512-NEXT: vextracti128 $1, %ymm0, %xmm1
|
||||
; AVX512-NEXT: vpsubd %xmm1, %xmm0, %xmm0
|
||||
; AVX512-NEXT: vzeroupper
|
||||
; AVX512-NEXT: retq
|
||||
%concat1 = shufflevector <4 x i32> %a, <4 x i32> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
%concat2 = shufflevector <4 x i32> %c, <4 x i32> %d, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
||||
%and = and <8 x i32> %concat1, %concat2
|
||||
%extract1 = shufflevector <8 x i32> %and, <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
||||
%extract2 = shufflevector <8 x i32> %and, <8 x i32> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
|
||||
%sub = sub <4 x i32> %extract1, %extract2
|
||||
ret <4 x i32> %sub
|
||||
}
|
||||
|
Loading…
Reference in New Issue