Skip to content

Commit 428c400

Browse files
author
ctopper
committed
[X86] Move the getInsertVINSERTImmediate and getExtractVEXTRACTImmediate helper functions over to X86ISelDAGToDAG.cpp
Redefine them to call getI8Imm and return that directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314059 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6dcd549 commit 428c400

File tree

4 files changed

+22
-70
lines changed

4 files changed

+22
-70
lines changed

lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,24 @@ namespace {
366366
return CurDAG->getTargetConstant(Imm, DL, MVT::i32);
367367
}
368368

369+
SDValue getExtractVEXTRACTImmediate(SDNode *N, unsigned VecWidth,
370+
const SDLoc &DL) {
371+
assert((VecWidth == 128 || VecWidth == 256) && "Unexpected vector width");
372+
uint64_t Index = N->getConstantOperandVal(1);
373+
MVT VecVT = N->getOperand(0).getSimpleValueType();
374+
unsigned NumElemsPerChunk = VecWidth / VecVT.getScalarSizeInBits();
375+
return getI8Imm(Index / NumElemsPerChunk, DL);
376+
}
377+
378+
SDValue getInsertVINSERTImmediate(SDNode *N, unsigned VecWidth,
379+
const SDLoc &DL) {
380+
assert((VecWidth == 128 || VecWidth == 256) && "Unexpected vector width");
381+
uint64_t Index = N->getConstantOperandVal(2);
382+
MVT VecVT = N->getSimpleValueType(0);
383+
unsigned NumElemsPerChunk = VecWidth / VecVT.getScalarSizeInBits();
384+
return getI8Imm(Index / NumElemsPerChunk, DL);
385+
}
386+
369387
/// Return an SDNode that returns the value of the global base register.
370388
/// Output instructions required to initialize the global base register,
371389
/// if necessary.

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,52 +4809,6 @@ static bool canWidenShuffleElements(ArrayRef<int> Mask,
48094809
return true;
48104810
}
48114811

4812-
static unsigned getExtractVEXTRACTImmediate(SDNode *N, unsigned vecWidth) {
4813-
assert((vecWidth == 128 || vecWidth == 256) && "Unsupported vector width");
4814-
assert(isa<ConstantSDNode>(N->getOperand(1).getNode()) &&
4815-
"Illegal extract subvector for VEXTRACT");
4816-
4817-
uint64_t Index = N->getConstantOperandVal(1);
4818-
MVT VecVT = N->getOperand(0).getSimpleValueType();
4819-
unsigned NumElemsPerChunk = vecWidth / VecVT.getScalarSizeInBits();
4820-
return Index / NumElemsPerChunk;
4821-
}
4822-
4823-
static unsigned getInsertVINSERTImmediate(SDNode *N, unsigned vecWidth) {
4824-
assert((vecWidth == 128 || vecWidth == 256) && "Unsupported vector width");
4825-
assert(isa<ConstantSDNode>(N->getOperand(2).getNode()) &&
4826-
"Illegal insert subvector for VINSERT");
4827-
4828-
uint64_t Index = N->getConstantOperandVal(2);
4829-
MVT VecVT = N->getSimpleValueType(0);
4830-
unsigned NumElemsPerChunk = vecWidth / VecVT.getScalarSizeInBits();
4831-
return Index / NumElemsPerChunk;
4832-
}
4833-
4834-
/// Return the appropriate immediate to extract the specified
4835-
/// EXTRACT_SUBVECTOR index with VEXTRACTF128 and VINSERTI128 instructions.
4836-
unsigned X86::getExtractVEXTRACT128Immediate(SDNode *N) {
4837-
return getExtractVEXTRACTImmediate(N, 128);
4838-
}
4839-
4840-
/// Return the appropriate immediate to extract the specified
4841-
/// EXTRACT_SUBVECTOR index with VEXTRACTF64x4 and VINSERTI64x4 instructions.
4842-
unsigned X86::getExtractVEXTRACT256Immediate(SDNode *N) {
4843-
return getExtractVEXTRACTImmediate(N, 256);
4844-
}
4845-
4846-
/// Return the appropriate immediate to insert at the specified
4847-
/// INSERT_SUBVECTOR index with VINSERTF128 and VINSERTI128 instructions.
4848-
unsigned X86::getInsertVINSERT128Immediate(SDNode *N) {
4849-
return getInsertVINSERTImmediate(N, 128);
4850-
}
4851-
4852-
/// Return the appropriate immediate to insert at the specified
4853-
/// INSERT_SUBVECTOR index with VINSERTF46x4 and VINSERTI64x4 instructions.
4854-
unsigned X86::getInsertVINSERT256Immediate(SDNode *N) {
4855-
return getInsertVINSERTImmediate(N, 256);
4856-
}
4857-
48584812
/// Returns true if Elt is a constant zero or a floating point constant +0.0.
48594813
bool X86::isZeroNode(SDValue Elt) {
48604814
return isNullConstant(Elt) || isNullFPConstant(Elt);

lib/Target/X86/X86ISelLowering.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -624,26 +624,6 @@ namespace llvm {
624624

625625
/// Define some predicates that are used for node matching.
626626
namespace X86 {
627-
/// Return the appropriate
628-
/// immediate to extract the specified EXTRACT_SUBVECTOR index
629-
/// with VEXTRACTF128, VEXTRACTI128 instructions.
630-
unsigned getExtractVEXTRACT128Immediate(SDNode *N);
631-
632-
/// Return the appropriate
633-
/// immediate to insert at the specified INSERT_SUBVECTOR index
634-
/// with VINSERTF128, VINSERT128 instructions.
635-
unsigned getInsertVINSERT128Immediate(SDNode *N);
636-
637-
/// Return the appropriate
638-
/// immediate to extract the specified EXTRACT_SUBVECTOR index
639-
/// with VEXTRACTF64X4, VEXTRACTI64x4 instructions.
640-
unsigned getExtractVEXTRACT256Immediate(SDNode *N);
641-
642-
/// Return the appropriate
643-
/// immediate to insert at the specified INSERT_SUBVECTOR index
644-
/// with VINSERTF64x4, VINSERTI64x4 instructions.
645-
unsigned getInsertVINSERT256Immediate(SDNode *N);
646-
647627
/// Returns true if Elt is a constant zero or floating point constant +0.0.
648628
bool isZeroNode(SDValue Elt);
649629

lib/Target/X86/X86InstrFragmentsSIMD.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,25 +884,25 @@ def BYTE_imm : SDNodeXForm<imm, [{
884884
// EXTRACT_get_vextract128_imm xform function: convert extract_subvector index
885885
// to VEXTRACTF128/VEXTRACTI128 imm.
886886
def EXTRACT_get_vextract128_imm : SDNodeXForm<extract_subvector, [{
887-
return getI8Imm(X86::getExtractVEXTRACT128Immediate(N), SDLoc(N));
887+
return getExtractVEXTRACTImmediate(N, 128, SDLoc(N));
888888
}]>;
889889

890890
// INSERT_get_vinsert128_imm xform function: convert insert_subvector index to
891891
// VINSERTF128/VINSERTI128 imm.
892892
def INSERT_get_vinsert128_imm : SDNodeXForm<insert_subvector, [{
893-
return getI8Imm(X86::getInsertVINSERT128Immediate(N), SDLoc(N));
893+
return getInsertVINSERTImmediate(N, 128, SDLoc(N));
894894
}]>;
895895

896896
// EXTRACT_get_vextract256_imm xform function: convert extract_subvector index
897897
// to VEXTRACTF64x4 imm.
898898
def EXTRACT_get_vextract256_imm : SDNodeXForm<extract_subvector, [{
899-
return getI8Imm(X86::getExtractVEXTRACT256Immediate(N), SDLoc(N));
899+
return getExtractVEXTRACTImmediate(N, 256, SDLoc(N));
900900
}]>;
901901

902902
// INSERT_get_vinsert256_imm xform function: convert insert_subvector index to
903903
// VINSERTF64x4 imm.
904904
def INSERT_get_vinsert256_imm : SDNodeXForm<insert_subvector, [{
905-
return getI8Imm(X86::getInsertVINSERT256Immediate(N), SDLoc(N));
905+
return getInsertVINSERTImmediate(N, 256, SDLoc(N));
906906
}]>;
907907

908908
def vextract128_extract : PatFrag<(ops node:$bigvec, node:$index),

0 commit comments

Comments
 (0)