Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5750,11 +5750,14 @@ AArch64TTIImpl::getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy,

Kind = improveShuffleKindFromMask(Kind, Mask, SrcTy, Index, SubTp);
bool IsExtractSubvector = Kind == TTI::SK_ExtractSubvector;
// A subvector extract can be implemented with an ext (or trivial extract, if
// from lane 0). This currently only handles low or high extracts to prevent
// SLP vectorizer regressions.
// A subvector extract can be implemented with a NEON/SVE ext (or trivial
// extract, if from lane 0) for 128-bit NEON vectors or legal SVE vectors.
// This currently only handles low or high extracts to prevent SLP vectorizer
// regressions.
// Note that SVE's ext instruction is destructive, but it can be fused with
// a movprfx to act like a constructive instruction.
if (IsExtractSubvector && LT.second.isFixedLengthVector()) {
if (LT.second.is128BitVector() &&
if (LT.second.getFixedSizeInBits() >= 128 &&
cast<FixedVectorType>(SubTp)->getNumElements() ==
LT.second.getVectorNumElements() / 2) {
if (Index == 0)
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/Analysis/CostModel/AArch64/shuffle-extract.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -mtriple=aarch64--linux-gnu -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output | FileCheck %s

; This tests the cost of fixed-length subvector extracts for NEON.
; For the SVE equivalent test, see sve-vls-shuffle-extract.ll

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"

define void @extract_half() {
Expand Down
Loading