mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 19:02:35 +00:00
[AVX] VEXTRACTF128 support. This commit includes patterns for
matching EXTRACT_SUBVECTOR to VEXTRACTF128 along with support routines to examine and translate index values. VINSERTF128 comes next. With these two in place we can begin supporting more AVX operations as INSERT/EXTRACT can be used as a fallback when 256-bit support is not available. llvm-svn: 124797
This commit is contained in:
parent
5c655f451e
commit
2753be260c
@ -3262,6 +3262,25 @@ bool X86::isMOVDDUPMask(ShuffleVectorSDNode *N) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// isVEXTRACTF128Index - Return true if the specified
|
||||
/// EXTRACT_SUBVECTOR operand specifies a vector extract that is
|
||||
/// suitable for input to VEXTRACTF128.
|
||||
bool X86::isVEXTRACTF128Index(SDNode *N) {
|
||||
if (!isa<ConstantSDNode>(N->getOperand(1).getNode()))
|
||||
return false;
|
||||
|
||||
// The index should be aligned on a 128-bit boundary.
|
||||
uint64_t Index =
|
||||
cast<ConstantSDNode>(N->getOperand(1).getNode())->getZExtValue();
|
||||
|
||||
unsigned VL = N->getValueType(0).getVectorNumElements();
|
||||
unsigned VBits = N->getValueType(0).getSizeInBits();
|
||||
unsigned ElSize = VBits / VL;
|
||||
bool Result = (Index * ElSize) % 128 == 0;
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// getShuffleSHUFImmediate - Return the appropriate immediate to shuffle
|
||||
/// the specified VECTOR_SHUFFLE mask with PSHUF* and SHUFP* instructions.
|
||||
unsigned X86::getShuffleSHUFImmediate(SDNode *N) {
|
||||
@ -3330,6 +3349,24 @@ unsigned X86::getShufflePALIGNRImmediate(SDNode *N) {
|
||||
return (Val - i) * EltSize;
|
||||
}
|
||||
|
||||
/// getExtractVEXTRACTF128Immediate - Return the appropriate immediate
|
||||
/// to extract the specified EXTRACT_SUBVECTOR index with VEXTRACTF128
|
||||
/// instructions.
|
||||
unsigned X86::getExtractVEXTRACTF128Immediate(SDNode *N) {
|
||||
if (!isa<ConstantSDNode>(N->getOperand(1).getNode()))
|
||||
llvm_unreachable("Illegal extract subvector for VEXTRACTF128");
|
||||
|
||||
uint64_t Index =
|
||||
cast<ConstantSDNode>(N->getOperand(1).getNode())->getZExtValue();
|
||||
|
||||
EVT VecVT = N->getOperand(0).getValueType();
|
||||
EVT ElVT = VecVT.getVectorElementType();
|
||||
|
||||
unsigned NumElemsPerChunk = 128 / ElVT.getSizeInBits();
|
||||
|
||||
return Index / NumElemsPerChunk;
|
||||
}
|
||||
|
||||
/// isZeroNode - Returns true if Elt is a constant zero or a floating point
|
||||
/// constant +0.0.
|
||||
bool X86::isZeroNode(SDValue Elt) {
|
||||
|
@ -408,6 +408,11 @@ namespace llvm {
|
||||
/// specifies a shuffle of elements that is suitable for input to PALIGNR.
|
||||
bool isPALIGNRMask(ShuffleVectorSDNode *N);
|
||||
|
||||
/// isVEXTRACTF128Index - Return true if the specified
|
||||
/// EXTRACT_SUBVECTOR operand specifies a vector extract that is
|
||||
/// suitable for input to VEXTRACTF128.
|
||||
bool isVEXTRACTF128Index(SDNode *N);
|
||||
|
||||
/// getShuffleSHUFImmediate - Return the appropriate immediate to shuffle
|
||||
/// the specified isShuffleMask VECTOR_SHUFFLE mask with PSHUF* and SHUFP*
|
||||
/// instructions.
|
||||
@ -425,6 +430,11 @@ namespace llvm {
|
||||
/// the specified VECTOR_SHUFFLE mask with the PALIGNR instruction.
|
||||
unsigned getShufflePALIGNRImmediate(SDNode *N);
|
||||
|
||||
/// getExtractVEXTRACTF128Immediate - Return the appropriate
|
||||
/// immediate to extract the specified EXTRACT_SUBVECTOR index
|
||||
/// with VEXTRACTF128 instructions.
|
||||
unsigned getExtractVEXTRACTF128Immediate(SDNode *N);
|
||||
|
||||
/// isZeroNode - Returns true if Elt is a constant zero or a floating point
|
||||
/// constant +0.0.
|
||||
bool isZeroNode(SDValue Elt);
|
||||
|
@ -342,6 +342,12 @@ def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
|
||||
return getI8Imm(X86::getShufflePALIGNRImmediate(N));
|
||||
}]>;
|
||||
|
||||
// EXTRACT_get_vextractf128_imm xform function: convert extract_subvector index
|
||||
// to VEXTRACTF128 imm.
|
||||
def EXTRACT_get_vextractf128_imm : SDNodeXForm<extract_subvector, [{
|
||||
return getI8Imm(X86::getExtractVEXTRACTF128Immediate(N));
|
||||
}]>;
|
||||
|
||||
def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
|
||||
(vector_shuffle node:$lhs, node:$rhs), [{
|
||||
ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
|
||||
@ -432,3 +438,9 @@ def palign : PatFrag<(ops node:$lhs, node:$rhs),
|
||||
(vector_shuffle node:$lhs, node:$rhs), [{
|
||||
return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
|
||||
}], SHUFFLE_get_palign_imm>;
|
||||
|
||||
def vextractf128_extract : PatFrag<(ops node:$bigvec, node:$index),
|
||||
(extract_subvector node:$bigvec,
|
||||
node:$index), [{
|
||||
return X86::isVEXTRACTF128Index(N);
|
||||
}], EXTRACT_get_vextractf128_imm>;
|
||||
|
@ -5443,6 +5443,23 @@ def : Pat<(int_x86_avx_vextractf128_ps_256 VR256:$src1, imm:$src2),
|
||||
def : Pat<(int_x86_avx_vextractf128_si_256 VR256:$src1, imm:$src2),
|
||||
(VEXTRACTF128rr VR256:$src1, imm:$src2)>;
|
||||
|
||||
def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
|
||||
(v4f32 (VEXTRACTF128rr
|
||||
(v8f32 VR256:$src1),
|
||||
(EXTRACT_get_vextractf128_imm VR128:$ext)))>;
|
||||
def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
|
||||
(v2f64 (VEXTRACTF128rr
|
||||
(v4f64 VR256:$src1),
|
||||
(EXTRACT_get_vextractf128_imm VR128:$ext)))>;
|
||||
def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
|
||||
(v4i32 (VEXTRACTF128rr
|
||||
(v8i32 VR256:$src1),
|
||||
(EXTRACT_get_vextractf128_imm VR128:$ext)))>;
|
||||
def : Pat<(vextractf128_extract:$ext VR256:$src1, (i32 imm)),
|
||||
(v2i64 (VEXTRACTF128rr
|
||||
(v4i64 VR256:$src1),
|
||||
(EXTRACT_get_vextractf128_imm VR128:$ext)))>;
|
||||
|
||||
def : Pat<(int_x86_avx_vbroadcastf128_ps_256 addr:$src),
|
||||
(VBROADCASTF128 addr:$src)>;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user