mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[X86] AVX512: Add writemask variants for vperm*2*
This includes assembler and codegen support (see the new tests in avx512-encodings.s and avx512-shuffle.ll). <rdar://problem/17492620> llvm-svn: 212221
This commit is contained in:
parent
e220f55c61
commit
ef83b36688
@ -609,7 +609,7 @@ defm VPERMPDZ : avx512_perm<0x16, "vpermpd", VR512, memopv8f64, f512mem,
|
||||
// -- VPERM2I - 3 source operands form --
|
||||
multiclass avx512_perm_3src<bits<8> opc, string OpcodeStr, RegisterClass RC,
|
||||
PatFrag mem_frag, X86MemOperand x86memop,
|
||||
SDNode OpNode, ValueType OpVT> {
|
||||
SDNode OpNode, ValueType OpVT, RegisterClass KRC> {
|
||||
let Constraints = "$src1 = $dst" in {
|
||||
def rr : AVX5128I<opc, MRMSrcReg, (outs RC:$dst),
|
||||
(ins RC:$src1, RC:$src2, RC:$src3),
|
||||
@ -619,32 +619,86 @@ let Constraints = "$src1 = $dst" in {
|
||||
(OpVT (OpNode RC:$src1, RC:$src2, RC:$src3)))]>,
|
||||
EVEX_4V;
|
||||
|
||||
def rrk : AVX5128I<opc, MRMSrcReg, (outs RC:$dst),
|
||||
(ins RC:$src1, KRC:$mask, RC:$src2, RC:$src3),
|
||||
!strconcat(OpcodeStr,
|
||||
" \t{$src3, $src2, $dst {${mask}}|"
|
||||
"$dst {${mask}}, $src2, $src3}"),
|
||||
[(set RC:$dst, (OpVT (vselect KRC:$mask,
|
||||
(OpNode RC:$src1, RC:$src2,
|
||||
RC:$src3),
|
||||
RC:$src1)))]>,
|
||||
EVEX_4V, EVEX_K;
|
||||
|
||||
let AddedComplexity = 30 in // Prefer over VMOV*rrkz Pat<>
|
||||
def rrkz : AVX5128I<opc, MRMSrcReg, (outs RC:$dst),
|
||||
(ins RC:$src1, KRC:$mask, RC:$src2, RC:$src3),
|
||||
!strconcat(OpcodeStr,
|
||||
" \t{$src3, $src2, $dst {${mask}} {z} |",
|
||||
"$dst {${mask}} {z}, $src2, $src3}"),
|
||||
[(set RC:$dst, (OpVT (vselect KRC:$mask,
|
||||
(OpNode RC:$src1, RC:$src2,
|
||||
RC:$src3),
|
||||
(OpVT (bitconvert
|
||||
(v16i32 immAllZerosV))))))]>,
|
||||
EVEX_4V, EVEX_KZ;
|
||||
|
||||
def rm : AVX5128I<opc, MRMSrcMem, (outs RC:$dst),
|
||||
(ins RC:$src1, RC:$src2, x86memop:$src3),
|
||||
!strconcat(OpcodeStr,
|
||||
" \t{$src3, $src2, $dst|$dst, $src2, $src3}"),
|
||||
[(set RC:$dst,
|
||||
(OpVT (OpNode RC:$src1, RC:$src2,
|
||||
(OpVT (OpNode RC:$src1, RC:$src2,
|
||||
(mem_frag addr:$src3))))]>, EVEX_4V;
|
||||
|
||||
def rmk : AVX5128I<opc, MRMSrcMem, (outs RC:$dst),
|
||||
(ins RC:$src1, KRC:$mask, RC:$src2, x86memop:$src3),
|
||||
!strconcat(OpcodeStr,
|
||||
" \t{$src3, $src2, $dst {${mask}}|"
|
||||
"$dst {${mask}}, $src2, $src3}"),
|
||||
[(set RC:$dst,
|
||||
(OpVT (vselect KRC:$mask,
|
||||
(OpNode RC:$src1, RC:$src2,
|
||||
(mem_frag addr:$src3)),
|
||||
RC:$src1)))]>,
|
||||
EVEX_4V, EVEX_K;
|
||||
|
||||
let AddedComplexity = 10 in // Prefer over the rrkz variant
|
||||
def rmkz : AVX5128I<opc, MRMSrcMem, (outs RC:$dst),
|
||||
(ins RC:$src1, KRC:$mask, RC:$src2, x86memop:$src3),
|
||||
!strconcat(OpcodeStr,
|
||||
" \t{$src3, $src2, $dst {${mask}} {z}|"
|
||||
"$dst {${mask}} {z}, $src2, $src3}"),
|
||||
[(set RC:$dst,
|
||||
(OpVT (vselect KRC:$mask,
|
||||
(OpNode RC:$src1, RC:$src2,
|
||||
(mem_frag addr:$src3)),
|
||||
(OpVT (bitconvert
|
||||
(v16i32 immAllZerosV))))))]>,
|
||||
EVEX_4V, EVEX_KZ;
|
||||
}
|
||||
}
|
||||
defm VPERMI2D : avx512_perm_3src<0x76, "vpermi2d", VR512, memopv16i32, i512mem,
|
||||
X86VPermiv3, v16i32>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMI2Q : avx512_perm_3src<0x76, "vpermi2q", VR512, memopv8i64, i512mem,
|
||||
X86VPermiv3, v8i64>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
defm VPERMI2PS : avx512_perm_3src<0x77, "vpermi2ps", VR512, memopv16f32, i512mem,
|
||||
X86VPermiv3, v16f32>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMI2PD : avx512_perm_3src<0x77, "vpermi2pd", VR512, memopv8f64, i512mem,
|
||||
X86VPermiv3, v8f64>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
defm VPERMI2D : avx512_perm_3src<0x76, "vpermi2d", VR512, memopv16i32,
|
||||
i512mem, X86VPermiv3, v16i32, VK16WM>,
|
||||
EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMI2Q : avx512_perm_3src<0x76, "vpermi2q", VR512, memopv8i64,
|
||||
i512mem, X86VPermiv3, v8i64, VK8WM>,
|
||||
EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
defm VPERMI2PS : avx512_perm_3src<0x77, "vpermi2ps", VR512, memopv16f32,
|
||||
i512mem, X86VPermiv3, v16f32, VK16WM>,
|
||||
EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMI2PD : avx512_perm_3src<0x77, "vpermi2pd", VR512, memopv8f64,
|
||||
i512mem, X86VPermiv3, v8f64, VK8WM>,
|
||||
EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
|
||||
defm VPERMT2D : avx512_perm_3src<0x7E, "vpermt2d", VR512, memopv16i32, i512mem,
|
||||
X86VPermv3, v16i32>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
X86VPermv3, v16i32, VK16WM>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMT2Q : avx512_perm_3src<0x7E, "vpermt2q", VR512, memopv8i64, i512mem,
|
||||
X86VPermv3, v8i64>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
X86VPermv3, v8i64, VK8WM>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
defm VPERMT2PS : avx512_perm_3src<0x7F, "vpermt2ps", VR512, memopv16f32, i512mem,
|
||||
X86VPermv3, v16f32>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
X86VPermv3, v16f32, VK16WM>, EVEX_V512, EVEX_CD8<32, CD8VF>;
|
||||
defm VPERMT2PD : avx512_perm_3src<0x7F, "vpermt2pd", VR512, memopv8f64, i512mem,
|
||||
X86VPermv3, v8f64>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
X86VPermv3, v8f64, VK8WM>, EVEX_V512, VEX_W, EVEX_CD8<64, CD8VF>;
|
||||
|
||||
def : Pat<(v16f32 (int_x86_avx512_mask_vpermt_ps_512 (v16i32 VR512:$idx),
|
||||
(v16f32 VR512:$src1), (v16f32 VR512:$src2), (i16 -1))),
|
||||
|
@ -56,6 +56,16 @@ define <8 x double> @test5(<8 x double> %a, <8 x double> %b) nounwind {
|
||||
ret <8 x double> %c
|
||||
}
|
||||
|
||||
; The reg variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test5m:
|
||||
; CHECK: vpermt2pd {{.* {%k[1-7]} {z}}}
|
||||
define <8 x double> @test5m(<8 x double> %a, <8 x double> %b, i8 %mask) nounwind {
|
||||
%c = shufflevector <8 x double> %a, <8 x double> %b, <8 x i32> <i32 2, i32 8, i32 0, i32 1, i32 6, i32 10, i32 4, i32 5>
|
||||
%m = bitcast i8 %mask to <8 x i1>
|
||||
%res = select <8 x i1> %m, <8 x double> %c, <8 x double> zeroinitializer
|
||||
ret <8 x double> %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test6:
|
||||
; CHECK: vpermq $30
|
||||
; CHECK: ret
|
||||
@ -72,6 +82,27 @@ define <8 x i64> @test7(<8 x i64> %a, <8 x i64> %b) nounwind {
|
||||
ret <8 x i64> %c
|
||||
}
|
||||
|
||||
; The reg variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test7m:
|
||||
; CHECK: vpermt2q {{.* {%k[1-7]} {z}}}
|
||||
define <8 x i64> @test7m(<8 x i64> %a, <8 x i64> %b, i8 %mask) nounwind {
|
||||
%c = shufflevector <8 x i64> %a, <8 x i64> %b, <8 x i32> <i32 2, i32 8, i32 0, i32 1, i32 6, i32 10, i32 4, i32 5>
|
||||
%m = bitcast i8 %mask to <8 x i1>
|
||||
%res = select <8 x i1> %m, <8 x i64> %c, <8 x i64> zeroinitializer
|
||||
ret <8 x i64> %res
|
||||
}
|
||||
|
||||
; The mem variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test7mm:
|
||||
; CHECK: vpermt2q {{\(.*\).* {%k[1-7]} {z}}}
|
||||
define <8 x i64> @test7mm(<8 x i64> %a, <8 x i64> *%pb, i8 %mask) nounwind {
|
||||
%b = load <8 x i64>* %pb
|
||||
%c = shufflevector <8 x i64> %a, <8 x i64> %b, <8 x i32> <i32 2, i32 8, i32 0, i32 1, i32 6, i32 10, i32 4, i32 5>
|
||||
%m = bitcast i8 %mask to <8 x i1>
|
||||
%res = select <8 x i1> %m, <8 x i64> %c, <8 x i64> zeroinitializer
|
||||
ret <8 x i64> %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test8:
|
||||
; CHECK: vpermt2d
|
||||
; CHECK: ret
|
||||
@ -80,6 +111,27 @@ define <16 x i32> @test8(<16 x i32> %a, <16 x i32> %b) nounwind {
|
||||
ret <16 x i32> %c
|
||||
}
|
||||
|
||||
; The reg variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test8m:
|
||||
; CHECK: vpermt2d {{.* {%k[1-7]} {z}}}
|
||||
define <16 x i32> @test8m(<16 x i32> %a, <16 x i32> %b, i16 %mask) nounwind {
|
||||
%c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
|
||||
%m = bitcast i16 %mask to <16 x i1>
|
||||
%res = select <16 x i1> %m, <16 x i32> %c, <16 x i32> zeroinitializer
|
||||
ret <16 x i32> %res
|
||||
}
|
||||
|
||||
; The mem variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test8mm:
|
||||
; CHECK: vpermt2d {{\(.*\).* {%k[1-7]} {z}}}
|
||||
define <16 x i32> @test8mm(<16 x i32> %a, <16 x i32> *%pb, i16 %mask) nounwind {
|
||||
%b = load <16 x i32> * %pb
|
||||
%c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
|
||||
%m = bitcast i16 %mask to <16 x i1>
|
||||
%res = select <16 x i1> %m, <16 x i32> %c, <16 x i32> zeroinitializer
|
||||
ret <16 x i32> %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test9:
|
||||
; CHECK: vpermt2ps
|
||||
; CHECK: ret
|
||||
@ -88,6 +140,16 @@ define <16 x float> @test9(<16 x float> %a, <16 x float> %b) nounwind {
|
||||
ret <16 x float> %c
|
||||
}
|
||||
|
||||
; The reg variant of vpermt2 with a writemask
|
||||
; CHECK-LABEL: test9m:
|
||||
; CHECK: vpermt2ps {{.*}} {%k{{.}}} {z}
|
||||
define <16 x float> @test9m(<16 x float> %a, <16 x float> %b, i16 %mask) nounwind {
|
||||
%c = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
|
||||
%m = bitcast i16 %mask to <16 x i1>
|
||||
%res = select <16 x i1> %m, <16 x float> %c, <16 x float> zeroinitializer
|
||||
ret <16 x float> %res
|
||||
}
|
||||
|
||||
; CHECK-LABEL: test10:
|
||||
; CHECK: vpermt2ps (
|
||||
; CHECK: ret
|
||||
|
@ -3199,3 +3199,19 @@ vpcmpd $1, %zmm24, %zmm7, %k5{%k4}
|
||||
// CHECK: vpcmpuq $2,
|
||||
// CHECK: encoding: [0x62,0xf3,0xf5,0x47,0x1e,0x72,0x01,0x02]
|
||||
vpcmpuq $2, 0x40(%rdx), %zmm17, %k6{%k7}
|
||||
|
||||
// CHECK: vpermi2d
|
||||
// CHECK: encoding: [0x62,0x42,0x6d,0x4b,0x76,0xd6]
|
||||
vpermi2d %zmm14, %zmm2, %zmm26 {%k3}
|
||||
|
||||
// CHECK: vpermt2pd
|
||||
// CHECK: encoding: [0x62,0xf2,0xcd,0xc6,0x7f,0xf3]
|
||||
vpermt2pd %zmm3, %zmm22, %zmm6 {%k6} {z}
|
||||
|
||||
// CHECK: vpermi2q
|
||||
// CHECK: encoding: [0x62,0x62,0xed,0x4b,0x76,0x54,0x58,0x02]
|
||||
vpermi2q 0x80(%rax,%rbx,2), %zmm2, %zmm26 {%k3}
|
||||
|
||||
// CHECK: vpermt2d
|
||||
// CHECK: encoding: [0x62,0x32,0x4d,0xc2,0x7e,0x24,0xad,0x05,0x00,0x00,0x00]
|
||||
vpermt2d 5(,%r13,4), %zmm22, %zmm12 {%k2} {z}
|
||||
|
Loading…
Reference in New Issue
Block a user