Skip to content

Commit 711b15d

Browse files
authored
[RISCV] Mark subvector extracts from index 0 as cheap (#134101)
Previously we only marked fixed length vector extracts as cheap, so this extends it to any extract at index 0 which should just be a subreg extract. This allows extracts of i1 vectors to be considered for DAG combines, but also scalable vectors too. This causes some slight improvements with large legalized fixed-length vectors, but the underlying motiviation for this is to actually prevent an unprofitable DAG combine on a scalable vector in an upcoming patch.
1 parent fa2a6d6 commit 711b15d

17 files changed

+5580
-6478
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,10 @@ bool RISCVTargetLowering::isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
22502250
if (!isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, ResVT))
22512251
return false;
22522252

2253+
// Extracts from index 0 are just subreg extracts.
2254+
if (Index == 0)
2255+
return true;
2256+
22532257
// Only support extracting a fixed from a fixed vector for now.
22542258
if (ResVT.isScalableVector() || SrcVT.isScalableVector())
22552259
return false;

0 commit comments

Comments
 (0)