Skip to content

Commit 2251ef9

Browse files
committed
[X86][ARM][TargetLowering] Add SrcVT to isExtractSubvectorCheap
Summary: Without the SrcVT its hard to know what is really being asked for. For example if your target has 128, 256, and 512 bit vectors. Maybe extracting 128 from 256 is cheap, but maybe extracting 128 from 512 is not. For x86 we do support extracting a quarter of a 512-bit register. But for i1 vectors we don't have isel patterns for extracting arbitrary pieces. So we need this to have a correct implementation of isExtractSubvectorCheap for mask vectors. Reviewers: RKSimon, zvi, efriedma Reviewed By: RKSimon Subscribers: aemerson, javed.absar, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D36649 llvm-svn: 310793
1 parent bed2c50 commit 2251ef9

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

llvm/include/llvm/Target/TargetLowering.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,11 +2172,12 @@ class TargetLoweringBase {
21722172
return false;
21732173
}
21742174

2175-
/// Return true if EXTRACT_SUBVECTOR is cheap for this result type
2176-
/// with this index. This is needed because EXTRACT_SUBVECTOR usually
2177-
/// has custom lowering that depends on the index of the first element,
2178-
/// and only the target knows which lowering is cheap.
2179-
virtual bool isExtractSubvectorCheap(EVT ResVT, unsigned Index) const {
2175+
/// Return true if EXTRACT_SUBVECTOR is cheap for extracting this result type
2176+
/// from this source type with this index. This is needed because
2177+
/// EXTRACT_SUBVECTOR usually has custom lowering that depends on the index of
2178+
/// the first element, and only the target knows which lowering is cheap.
2179+
virtual bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
2180+
unsigned Index) const {
21802181
return false;
21812182
}
21822183

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14212,7 +14212,7 @@ SDValue DAGCombiner::createBuildVecShuffle(const SDLoc &DL, SDNode *N,
1421214212
VecIn1 = DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, ConcatOps);
1421314213
VecIn2 = SDValue();
1421414214
} else if (InVT1.getSizeInBits() == VT.getSizeInBits() * 2) {
14215-
if (!TLI.isExtractSubvectorCheap(VT, NumElems))
14215+
if (!TLI.isExtractSubvectorCheap(VT, InVT1, NumElems))
1421614216
return SDValue();
1421714217

1421814218
if (!VecIn2.getNode()) {

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13402,7 +13402,7 @@ bool ARMTargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
1340213402
return true;
1340313403
}
1340413404

13405-
bool ARMTargetLowering::isExtractSubvectorCheap(EVT ResVT,
13405+
bool ARMTargetLowering::isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
1340613406
unsigned Index) const {
1340713407
if (!isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, ResVT))
1340813408
return false;

llvm/lib/Target/ARM/ARMISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ class InstrItineraryData;
459459

460460
/// Return true if EXTRACT_SUBVECTOR is cheap for this result type
461461
/// with this index.
462-
bool isExtractSubvectorCheap(EVT ResVT, unsigned Index) const override;
462+
bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
463+
unsigned Index) const override;
463464

464465
/// \brief Returns true if an argument of type Ty needs to be passed in a
465466
/// contiguous block of registers in calling convention CallConv.

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4574,7 +4574,7 @@ bool X86TargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
45744574
return true;
45754575
}
45764576

4577-
bool X86TargetLowering::isExtractSubvectorCheap(EVT ResVT,
4577+
bool X86TargetLowering::isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
45784578
unsigned Index) const {
45794579
if (!isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, ResVT))
45804580
return false;

llvm/lib/Target/X86/X86ISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ namespace llvm {
10361036

10371037
/// Return true if EXTRACT_SUBVECTOR is cheap for this result type
10381038
/// with this index.
1039-
bool isExtractSubvectorCheap(EVT ResVT, unsigned Index) const override;
1039+
bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
1040+
unsigned Index) const override;
10401041

10411042
/// Intel processors have a unified instruction and data cache
10421043
const char * getClearCacheBuiltinName() const override {

0 commit comments

Comments
 (0)