mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
AVX-512: implemented extractelement with variable index.
Added parsing of mask register and "zeroing" semantic, like {%k1} {z}. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
112f7a637b
commit
f9d2d2dc89
@ -1978,6 +1978,47 @@ ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc,
|
||||
}
|
||||
}
|
||||
|
||||
if (STI.getFeatureBits() & X86::FeatureAVX512) {
|
||||
// Parse mask register {%k1}
|
||||
if (getLexer().is(AsmToken::LCurly)) {
|
||||
SMLoc Loc = Parser.getTok().getLoc();
|
||||
Operands.push_back(X86Operand::CreateToken("{", Loc));
|
||||
Parser.Lex(); // Eat the {
|
||||
if (X86Operand *Op = ParseOperand()) {
|
||||
Operands.push_back(Op);
|
||||
if (!getLexer().is(AsmToken::RCurly)) {
|
||||
SMLoc Loc = getLexer().getLoc();
|
||||
Parser.eatToEndOfStatement();
|
||||
return Error(Loc, "Expected } at this point");
|
||||
}
|
||||
Loc = Parser.getTok().getLoc();
|
||||
Operands.push_back(X86Operand::CreateToken("}", Loc));
|
||||
Parser.Lex(); // Eat the }
|
||||
} else {
|
||||
Parser.eatToEndOfStatement();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Parse "zeroing non-masked" semantic {z}
|
||||
if (getLexer().is(AsmToken::LCurly)) {
|
||||
SMLoc Loc = Parser.getTok().getLoc();
|
||||
Operands.push_back(X86Operand::CreateToken("{z}", Loc));
|
||||
Parser.Lex(); // Eat the {
|
||||
if (!getLexer().is(AsmToken::Identifier) || getLexer().getTok().getIdentifier() != "z") {
|
||||
SMLoc Loc = getLexer().getLoc();
|
||||
Parser.eatToEndOfStatement();
|
||||
return Error(Loc, "Expected z at this point");
|
||||
}
|
||||
Parser.Lex(); // Eat the z
|
||||
if (!getLexer().is(AsmToken::RCurly)) {
|
||||
SMLoc Loc = getLexer().getLoc();
|
||||
Parser.eatToEndOfStatement();
|
||||
return Error(Loc, "Expected } at this point");
|
||||
}
|
||||
Parser.Lex(); // Eat the }
|
||||
}
|
||||
}
|
||||
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
SMLoc Loc = getLexer().getLoc();
|
||||
Parser.eatToEndOfStatement();
|
||||
|
@ -7601,18 +7601,40 @@ SDValue
|
||||
X86TargetLowering::LowerEXTRACT_VECTOR_ELT(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
SDLoc dl(Op);
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(1)))
|
||||
return SDValue();
|
||||
|
||||
SDValue Vec = Op.getOperand(0);
|
||||
MVT VecVT = Vec.getSimpleValueType();
|
||||
SDValue Idx = Op.getOperand(1);
|
||||
if (!isa<ConstantSDNode>(Idx)) {
|
||||
if (VecVT.is512BitVector() ||
|
||||
(VecVT.is256BitVector() && Subtarget->hasInt256() &&
|
||||
VecVT.getVectorElementType().getSizeInBits() == 32)) {
|
||||
|
||||
MVT MaskEltVT =
|
||||
MVT::getIntegerVT(VecVT.getVectorElementType().getSizeInBits());
|
||||
MVT MaskVT = MVT::getVectorVT(MaskEltVT, VecVT.getSizeInBits() /
|
||||
MaskEltVT.getSizeInBits());
|
||||
|
||||
if (Idx.getSimpleValueType() != MaskEltVT)
|
||||
if (Idx.getOpcode() == ISD::ZERO_EXTEND ||
|
||||
Idx.getOpcode() == ISD::SIGN_EXTEND)
|
||||
Idx = Idx.getOperand(0);
|
||||
assert(Idx.getSimpleValueType() == MaskEltVT &&
|
||||
"Unexpected index in insertelement");
|
||||
SDValue Mask = DAG.getNode(X86ISD::VINSERT, dl, MaskVT,
|
||||
getZeroVector(MaskVT, Subtarget, DAG, dl),
|
||||
Idx, DAG.getConstant(0, getPointerTy()));
|
||||
SDValue Perm = DAG.getNode(X86ISD::VPERMV, dl, VecVT, Mask, Vec);
|
||||
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, Op.getValueType(),
|
||||
Perm, DAG.getConstant(0, getPointerTy()));
|
||||
}
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
// If this is a 256-bit vector result, first extract the 128-bit vector and
|
||||
// then extract the element from the 128-bit vector.
|
||||
if (VecVT.is256BitVector() || VecVT.is512BitVector()) {
|
||||
SDValue Idx = Op.getOperand(1);
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
|
||||
unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
// Get the 128-bit vector.
|
||||
Vec = Extract128BitVector(Vec, IdxVal, DAG, dl);
|
||||
MVT EltVT = VecVT.getVectorElementType();
|
||||
@ -13663,6 +13685,7 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
|
||||
case X86ISD::VSEXT: return "X86ISD::VSEXT";
|
||||
case X86ISD::VTRUNC: return "X86ISD::VTRUNC";
|
||||
case X86ISD::VTRUNCM: return "X86ISD::VTRUNCM";
|
||||
case X86ISD::VINSERT: return "X86ISD::VINSERT";
|
||||
case X86ISD::VFPEXT: return "X86ISD::VFPEXT";
|
||||
case X86ISD::VFPROUND: return "X86ISD::VFPROUND";
|
||||
case X86ISD::VSHLDQ: return "X86ISD::VSHLDQ";
|
||||
|
@ -342,6 +342,7 @@ namespace llvm {
|
||||
VBROADCAST,
|
||||
// masked broadcast
|
||||
VBROADCASTM,
|
||||
VINSERT,
|
||||
|
||||
// PMULUDQ - Vector multiply packed unsigned doubleword integers
|
||||
PMULUDQ,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -221,6 +221,8 @@ def X86VPerm2x128 : SDNode<"X86ISD::VPERM2X128", SDTShuff3OpI>;
|
||||
|
||||
def X86VBroadcast : SDNode<"X86ISD::VBROADCAST", SDTVBroadcast>;
|
||||
def X86VBroadcastm : SDNode<"X86ISD::VBROADCASTM", SDTVBroadcastm>;
|
||||
def X86Vinsert : SDNode<"X86ISD::VINSERT", SDTypeProfile<1, 3,
|
||||
[SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
|
||||
|
||||
def X86Blendi : SDNode<"X86ISD::BLENDI", SDTBlend>;
|
||||
def X86Fmadd : SDNode<"X86ISD::FMADD", SDTFma>;
|
||||
|
@ -4444,6 +4444,18 @@ def MOVPDI2DImr : S2I<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
|
||||
(iPTR 0))), addr:$dst)],
|
||||
IIC_SSE_MOVDQ>, Sched<[WriteLoad]>;
|
||||
|
||||
def : Pat<(v8i32 (X86Vinsert (v8i32 immAllZerosV), GR32:$src2, (iPTR 0))),
|
||||
(SUBREG_TO_REG (i32 0), (VMOVDI2PDIrr GR32:$src2), sub_xmm)>;
|
||||
|
||||
def : Pat<(v4i64 (X86Vinsert (bc_v4i64 (v8i32 immAllZerosV)), GR64:$src2, (iPTR 0))),
|
||||
(SUBREG_TO_REG (i32 0), (VMOV64toPQIrr GR64:$src2), sub_xmm)>;
|
||||
|
||||
def : Pat<(v8i32 (X86Vinsert undef, GR32:$src2, (iPTR 0))),
|
||||
(SUBREG_TO_REG (i32 0), (VMOVDI2PDIrr GR32:$src2), sub_xmm)>;
|
||||
|
||||
def : Pat<(v4i64 (X86Vinsert undef, GR64:$src2, (iPTR 0))),
|
||||
(SUBREG_TO_REG (i32 0), (VMOV64toPQIrr GR64:$src2), sub_xmm)>;
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
// Move Packed Doubleword Int first element to Doubleword Int
|
||||
//
|
||||
|
@ -61,3 +61,40 @@ define void @test6(<4 x float> %x, float* %out) nounwind {
|
||||
ret void
|
||||
}
|
||||
|
||||
;CHECK-LABEL: test7
|
||||
;CHECK: vmovdz
|
||||
;CHECK: vpermps %zmm
|
||||
;CHECK: ret
|
||||
define float @test7(<16 x float> %x, i32 %ind) nounwind {
|
||||
%e = extractelement <16 x float> %x, i32 %ind
|
||||
ret float %e
|
||||
}
|
||||
|
||||
;CHECK-LABEL: test8
|
||||
;CHECK: vmovqz
|
||||
;CHECK: vpermpd %zmm
|
||||
;CHECK: ret
|
||||
define double @test8(<8 x double> %x, i32 %ind) nounwind {
|
||||
%e = extractelement <8 x double> %x, i32 %ind
|
||||
ret double %e
|
||||
}
|
||||
|
||||
;CHECK-LABEL: test9
|
||||
;CHECK: vmovd
|
||||
;CHECK: vpermps %ymm
|
||||
;CHECK: ret
|
||||
define float @test9(<8 x float> %x, i32 %ind) nounwind {
|
||||
%e = extractelement <8 x float> %x, i32 %ind
|
||||
ret float %e
|
||||
}
|
||||
|
||||
;CHECK-LABEL: test10
|
||||
;CHECK: vmovdz
|
||||
;CHECK: vpermd %zmm
|
||||
;CHEKK: vmovdz %xmm0, %eax
|
||||
;CHECK: ret
|
||||
define i32 @test10(<16 x i32> %x, i32 %ind) nounwind {
|
||||
%e = extractelement <16 x i32> %x, i32 %ind
|
||||
ret i32 %e
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ define <8 x double> @fpext_test(<8 x float> %a) nounwind readnone {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: zext_16i1_to_16xi32
|
||||
; CHECK: vpbroadcastd LCP{{.*}}(%rip), %zmm0{%k1}{z}
|
||||
; CHECK: vpbroadcastd LCP{{.*}}(%rip), %zmm0 {%k1} {z}
|
||||
; CHECK: ret
|
||||
define <16 x i32> @zext_16i1_to_16xi32(i16 %b) {
|
||||
%a = bitcast i16 %b to <16 x i1>
|
||||
@ -76,7 +76,7 @@ define <16 x i32> @zext_16i1_to_16xi32(i16 %b) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: zext_8i1_to_8xi64
|
||||
; CHECK: vpbroadcastq LCP{{.*}}(%rip), %zmm0{%k1}{z}
|
||||
; CHECK: vpbroadcastq LCP{{.*}}(%rip), %zmm0 {%k1} {z}
|
||||
; CHECK: ret
|
||||
define <8 x i64> @zext_8i1_to_8xi64(i8 %b) {
|
||||
%a = bitcast i8 %b to <8 x i1>
|
||||
@ -117,7 +117,7 @@ define i8 @trunc_8i16_to_8i1(<8 x i16> %a) {
|
||||
}
|
||||
|
||||
; CHECK: sext_8i1_8i32
|
||||
; CHECK: vpbroadcastq LCP{{.*}}(%rip), %zmm0{%k1}{z}
|
||||
; CHECK: vpbroadcastq LCP{{.*}}(%rip), %zmm0 {%k1} {z}
|
||||
; CHECK: ret
|
||||
define <8 x i32> @sext_8i1_8i32(<8 x i32> %a1, <8 x i32> %a2) nounwind {
|
||||
%x = icmp slt <8 x i32> %a1, %a2
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s
|
||||
// RUN: llvm-mc -triple x86_64-unknown-unknown -mcpu=knl --show-encoding %s | FileCheck %s
|
||||
|
||||
// CHECK: vinserti32x4
|
||||
// CHECK: encoding: [0x62,0xa3,0x55,0x48,0x38,0xcd,0x01]
|
||||
@ -35,3 +35,11 @@ vpsrad %xmm17, %zmm12, %zmm25
|
||||
// CHECK: vpsrad
|
||||
// CHECK: encoding: [0x62,0x61,0x1d,0x48,0xe2,0x4c,0xb7,0x20]
|
||||
vpsrad 512(%rdi, %rsi, 4), %zmm12, %zmm25
|
||||
|
||||
// CHECK: vpbroadcastd {{.*}} {%k1} {z}
|
||||
// CHECK: encoding: [0x62,0xf2,0x7d,0xc9,0x58,0xc8]
|
||||
vpbroadcastd %xmm0, %zmm1 {%k1} {z}
|
||||
|
||||
// CHECK: vmovdqu64 {{.*}} {%k3}
|
||||
// CHECK: encoding: [0x62,0xf1,0xfe,0x4b,0x6f,0xc8]
|
||||
vmovdqu64 %zmm0, %zmm1 {%k3}
|
Loading…
Reference in New Issue
Block a user