Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 28 additions & 0 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,28 @@ static std::optional<Instruction *> instCombinePTrue(InstCombiner &IC,
return std::nullopt;
}

static std::optional<Instruction *> instCombineSVEUxt(InstCombiner &IC,
IntrinsicInst &II,
unsigned NumBits) {
Value *Passthru = II.getOperand(0);
Value *Pg = II.getOperand(1);
Value *Op = II.getOperand(2);

// Convert UXT[BHW] to AND.
if (isa<UndefValue>(Passthru) || isAllActivePredicate(Pg)) {
auto *Ty = cast<VectorType>(II.getType());
auto MaskValue = APInt::getLowBitsSet(Ty->getScalarSizeInBits(), NumBits);
auto *Mask = ConstantVector::getSplat(
Ty->getElementCount(),
ConstantInt::get(Ty->getElementType(), MaskValue));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto *Mask = ConstantVector::getSplat(
Ty->getElementCount(),
ConstantInt::get(Ty->getElementType(), MaskValue));
auto *Mask = ConstantInt::get(Ty, MaskValue);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, thanks - done.

auto *And = IC.Builder.CreateIntrinsic(Intrinsic::aarch64_sve_and_u, {Ty},
{Pg, Op, Mask});
return IC.replaceInstUsesWith(II, And);
}

return std::nullopt;
}

std::optional<Instruction *>
AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC,
IntrinsicInst &II) const {
Expand Down Expand Up @@ -2745,6 +2767,12 @@ AArch64TTIImpl::instCombineIntrinsic(InstCombiner &IC,
return instCombineSVEInsr(IC, II);
case Intrinsic::aarch64_sve_ptrue:
return instCombinePTrue(IC, II);
case Intrinsic::aarch64_sve_uxtb:
return instCombineSVEUxt(IC, II, 8);
case Intrinsic::aarch64_sve_uxth:
return instCombineSVEUxt(IC, II, 16);
case Intrinsic::aarch64_sve_uxtw:
return instCombineSVEUxt(IC, II, 32);
}

return std::nullopt;
Expand Down
Loading
Loading