Skip to content

Commit df2356b

Browse files
committed
[X86] getShuffleCost - ensure we treat constant folded shuffles as free
1 parent fbdbb13 commit df2356b

File tree

2 files changed

+67
-127
lines changed

2 files changed

+67
-127
lines changed

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,11 @@ InstructionCost X86TTIImpl::getShuffleCost(
15321532

15331533
Kind = improveShuffleKindFromMask(Kind, Mask, BaseTp, Index, SubTp);
15341534

1535+
// If all args are constant than this will be constant folded away.
1536+
if (!Args.empty() &&
1537+
all_of(Args, [](const Value *Arg) { return isa<Constant>(Arg); }))
1538+
return TTI::TCC_Free;
1539+
15351540
// Recognize a basic concat_vector shuffle.
15361541
if (Kind == TTI::SK_PermuteTwoSrc &&
15371542
Mask.size() == (2 * BaseTp->getElementCount().getKnownMinValue()) &&

0 commit comments

Comments
 (0)