Skip to content

Commit d93e136

Browse files
committed
[aarch64] move custom isel of extract_vector_elt to td file - NFC
In preparation for def-pat selection of dot product instructions, this patch moves the custom instruction selection of extract_vector_elt to the td file. Without this change it is impossible to catch a pattern that starts with an extract_vector_elt: the custom cpp code is executed first ahead of the patterns in the td files that are only executed at the end of the switch statement in SelectCode(Node). With this patch applied, it becomes possible to select a different pattern that starts with extract_vector_elt by selecting a higher complexity than this pattern. The patch has been tested on aarch64-linux with make check-all. Differential Revision: https://reviews.llvm.org/D67497 llvm-svn: 371887
1 parent e210c03 commit d93e136

File tree

2 files changed

+10
-43
lines changed

2 files changed

+10
-43
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,49 +2913,6 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
29132913
return;
29142914
break;
29152915

2916-
case ISD::EXTRACT_VECTOR_ELT: {
2917-
// Extracting lane zero is a special case where we can just use a plain
2918-
// EXTRACT_SUBREG instruction, which will become FMOV. This is easier for
2919-
// the rest of the compiler, especially the register allocator and copyi
2920-
// propagation, to reason about, so is preferred when it's possible to
2921-
// use it.
2922-
ConstantSDNode *LaneNode = cast<ConstantSDNode>(Node->getOperand(1));
2923-
// Bail and use the default Select() for non-zero lanes.
2924-
if (LaneNode->getZExtValue() != 0)
2925-
break;
2926-
// If the element type is not the same as the result type, likewise
2927-
// bail and use the default Select(), as there's more to do than just
2928-
// a cross-class COPY. This catches extracts of i8 and i16 elements
2929-
// since they will need an explicit zext.
2930-
if (VT != Node->getOperand(0).getValueType().getVectorElementType())
2931-
break;
2932-
unsigned SubReg;
2933-
switch (Node->getOperand(0)
2934-
.getValueType()
2935-
.getVectorElementType()
2936-
.getSizeInBits()) {
2937-
default:
2938-
llvm_unreachable("Unexpected vector element type!");
2939-
case 64:
2940-
SubReg = AArch64::dsub;
2941-
break;
2942-
case 32:
2943-
SubReg = AArch64::ssub;
2944-
break;
2945-
case 16:
2946-
SubReg = AArch64::hsub;
2947-
break;
2948-
case 8:
2949-
llvm_unreachable("unexpected zext-requiring extract element!");
2950-
}
2951-
SDValue Extract = CurDAG->getTargetExtractSubreg(SubReg, SDLoc(Node), VT,
2952-
Node->getOperand(0));
2953-
LLVM_DEBUG(dbgs() << "ISEL: Custom selection!\n=> ");
2954-
LLVM_DEBUG(Extract->dumpr(CurDAG));
2955-
LLVM_DEBUG(dbgs() << "\n");
2956-
ReplaceNode(Node, Extract.getNode());
2957-
return;
2958-
}
29592916
case ISD::Constant: {
29602917
// Materialize zero constants as copies from WZR/XZR. This allows
29612918
// the coalescer to propagate these into other instructions.

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6973,5 +6973,15 @@ def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
69736973
def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
69746974
def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
69756975

6976+
// Extracting lane zero is a special case where we can just use a plain
6977+
// EXTRACT_SUBREG instruction, which will become FMOV. This is easier for the
6978+
// rest of the compiler, especially the register allocator and copy propagation,
6979+
// to reason about, so is preferred when it's possible to use it.
6980+
let AddedComplexity = 10 in {
6981+
def : Pat<(i64 (extractelt (v2i64 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, dsub)>;
6982+
def : Pat<(i32 (extractelt (v4i32 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, ssub)>;
6983+
def : Pat<(i32 (extractelt (v2i32 V64:$V), (i64 0))), (EXTRACT_SUBREG V64:$V, ssub)>;
6984+
}
6985+
69766986
include "AArch64InstrAtomics.td"
69776987
include "AArch64SVEInstrInfo.td"

0 commit comments

Comments
 (0)