mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[IRBuilder] Add type argument to CreateMaskedLoad/Gather
Same as other CreateLoad-style APIs, these need an explicit type argument to support opaque pointers. Differential Revision: https://reviews.llvm.org/D105395
This commit is contained in:
parent
b463417679
commit
ecd2dc975e
@ -752,7 +752,7 @@ public:
|
|||||||
CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr);
|
CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr);
|
||||||
|
|
||||||
/// Create a call to Masked Load intrinsic
|
/// Create a call to Masked Load intrinsic
|
||||||
CallInst *CreateMaskedLoad(Value *Ptr, Align Alignment, Value *Mask,
|
CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask,
|
||||||
Value *PassThru = nullptr, const Twine &Name = "");
|
Value *PassThru = nullptr, const Twine &Name = "");
|
||||||
|
|
||||||
/// Create a call to Masked Store intrinsic
|
/// Create a call to Masked Store intrinsic
|
||||||
@ -760,7 +760,7 @@ public:
|
|||||||
Value *Mask);
|
Value *Mask);
|
||||||
|
|
||||||
/// Create a call to Masked Gather intrinsic
|
/// Create a call to Masked Gather intrinsic
|
||||||
CallInst *CreateMaskedGather(Value *Ptrs, Align Alignment,
|
CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment,
|
||||||
Value *Mask = nullptr, Value *PassThru = nullptr,
|
Value *Mask = nullptr, Value *PassThru = nullptr,
|
||||||
const Twine &Name = "");
|
const Twine &Name = "");
|
||||||
|
|
||||||
|
@ -1421,10 +1421,9 @@ static Value *UpgradeMaskedLoad(IRBuilder<> &Builder,
|
|||||||
return Builder.CreateAlignedLoad(ValTy, Ptr, Alignment);
|
return Builder.CreateAlignedLoad(ValTy, Ptr, Alignment);
|
||||||
|
|
||||||
// Convert the mask from an integer type to a vector of i1.
|
// Convert the mask from an integer type to a vector of i1.
|
||||||
unsigned NumElts =
|
unsigned NumElts = cast<FixedVectorType>(ValTy)->getNumElements();
|
||||||
cast<FixedVectorType>(Passthru->getType())->getNumElements();
|
|
||||||
Mask = getX86MaskVec(Builder, Mask, NumElts);
|
Mask = getX86MaskVec(Builder, Mask, NumElts);
|
||||||
return Builder.CreateMaskedLoad(Ptr, Alignment, Mask, Passthru);
|
return Builder.CreateMaskedLoad(ValTy, Ptr, Alignment, Mask, Passthru);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value *upgradeAbs(IRBuilder<> &Builder, CallInst &CI) {
|
static Value *upgradeAbs(IRBuilder<> &Builder, CallInst &CI) {
|
||||||
|
@ -493,6 +493,7 @@ Instruction *IRBuilderBase::CreateNoAliasScopeDeclaration(Value *Scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a call to a Masked Load intrinsic.
|
/// Create a call to a Masked Load intrinsic.
|
||||||
|
/// \p Ty - vector type to load
|
||||||
/// \p Ptr - base pointer for the load
|
/// \p Ptr - base pointer for the load
|
||||||
/// \p Alignment - alignment of the source location
|
/// \p Alignment - alignment of the source location
|
||||||
/// \p Mask - vector of booleans which indicates what vector lanes should
|
/// \p Mask - vector of booleans which indicates what vector lanes should
|
||||||
@ -500,16 +501,16 @@ Instruction *IRBuilderBase::CreateNoAliasScopeDeclaration(Value *Scope) {
|
|||||||
/// \p PassThru - pass-through value that is used to fill the masked-off lanes
|
/// \p PassThru - pass-through value that is used to fill the masked-off lanes
|
||||||
/// of the result
|
/// of the result
|
||||||
/// \p Name - name of the result variable
|
/// \p Name - name of the result variable
|
||||||
CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, Align Alignment,
|
CallInst *IRBuilderBase::CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment,
|
||||||
Value *Mask, Value *PassThru,
|
Value *Mask, Value *PassThru,
|
||||||
const Twine &Name) {
|
const Twine &Name) {
|
||||||
auto *PtrTy = cast<PointerType>(Ptr->getType());
|
auto *PtrTy = cast<PointerType>(Ptr->getType());
|
||||||
Type *DataTy = PtrTy->getElementType();
|
assert(Ty->isVectorTy() && "Type should be vector");
|
||||||
assert(DataTy->isVectorTy() && "Ptr should point to a vector");
|
assert(PtrTy->isOpaqueOrPointeeTypeMatches(Ty) && "Wrong element type");
|
||||||
assert(Mask && "Mask should not be all-ones (null)");
|
assert(Mask && "Mask should not be all-ones (null)");
|
||||||
if (!PassThru)
|
if (!PassThru)
|
||||||
PassThru = UndefValue::get(DataTy);
|
PassThru = UndefValue::get(Ty);
|
||||||
Type *OverloadedTypes[] = { DataTy, PtrTy };
|
Type *OverloadedTypes[] = { Ty, PtrTy };
|
||||||
Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
|
Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
|
||||||
return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
|
return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
|
||||||
OverloadedTypes, Name);
|
OverloadedTypes, Name);
|
||||||
@ -546,6 +547,7 @@ CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a call to a Masked Gather intrinsic.
|
/// Create a call to a Masked Gather intrinsic.
|
||||||
|
/// \p Ty - vector type to gather
|
||||||
/// \p Ptrs - vector of pointers for loading
|
/// \p Ptrs - vector of pointers for loading
|
||||||
/// \p Align - alignment for one element
|
/// \p Align - alignment for one element
|
||||||
/// \p Mask - vector of booleans which indicates what vector lanes should
|
/// \p Mask - vector of booleans which indicates what vector lanes should
|
||||||
@ -553,22 +555,27 @@ CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
|
|||||||
/// \p PassThru - pass-through value that is used to fill the masked-off lanes
|
/// \p PassThru - pass-through value that is used to fill the masked-off lanes
|
||||||
/// of the result
|
/// of the result
|
||||||
/// \p Name - name of the result variable
|
/// \p Name - name of the result variable
|
||||||
CallInst *IRBuilderBase::CreateMaskedGather(Value *Ptrs, Align Alignment,
|
CallInst *IRBuilderBase::CreateMaskedGather(Type *Ty, Value *Ptrs,
|
||||||
Value *Mask, Value *PassThru,
|
Align Alignment, Value *Mask,
|
||||||
|
Value *PassThru,
|
||||||
const Twine &Name) {
|
const Twine &Name) {
|
||||||
|
auto *VecTy = cast<VectorType>(Ty);
|
||||||
|
ElementCount NumElts = VecTy->getElementCount();
|
||||||
auto *PtrsTy = cast<VectorType>(Ptrs->getType());
|
auto *PtrsTy = cast<VectorType>(Ptrs->getType());
|
||||||
auto *PtrTy = cast<PointerType>(PtrsTy->getElementType());
|
assert(cast<PointerType>(PtrsTy->getElementType())
|
||||||
ElementCount NumElts = PtrsTy->getElementCount();
|
->isOpaqueOrPointeeTypeMatches(
|
||||||
auto *DataTy = VectorType::get(PtrTy->getElementType(), NumElts);
|
cast<VectorType>(Ty)->getElementType()) &&
|
||||||
|
"Element type mismatch");
|
||||||
|
assert(NumElts == PtrsTy->getElementCount() && "Element count mismatch");
|
||||||
|
|
||||||
if (!Mask)
|
if (!Mask)
|
||||||
Mask = Constant::getAllOnesValue(
|
Mask = Constant::getAllOnesValue(
|
||||||
VectorType::get(Type::getInt1Ty(Context), NumElts));
|
VectorType::get(Type::getInt1Ty(Context), NumElts));
|
||||||
|
|
||||||
if (!PassThru)
|
if (!PassThru)
|
||||||
PassThru = UndefValue::get(DataTy);
|
PassThru = UndefValue::get(Ty);
|
||||||
|
|
||||||
Type *OverloadedTypes[] = {DataTy, PtrsTy};
|
Type *OverloadedTypes[] = {Ty, PtrsTy};
|
||||||
Value *Ops[] = {Ptrs, getInt32(Alignment.value()), Mask, PassThru};
|
Value *Ops[] = {Ptrs, getInt32(Alignment.value()), Mask, PassThru};
|
||||||
|
|
||||||
// We specify only one type when we create this intrinsic. Types of other
|
// We specify only one type when we create this intrinsic. Types of other
|
||||||
|
@ -475,7 +475,7 @@ auto AlignVectors::createAlignedLoad(IRBuilder<> &Builder, Type *ValTy,
|
|||||||
return PassThru;
|
return PassThru;
|
||||||
if (Mask == ConstantInt::getTrue(Mask->getType()))
|
if (Mask == ConstantInt::getTrue(Mask->getType()))
|
||||||
return Builder.CreateAlignedLoad(ValTy, Ptr, Align(Alignment));
|
return Builder.CreateAlignedLoad(ValTy, Ptr, Align(Alignment));
|
||||||
return Builder.CreateMaskedLoad(Ptr, Align(Alignment), Mask, PassThru);
|
return Builder.CreateMaskedLoad(ValTy, Ptr, Align(Alignment), Mask, PassThru);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AlignVectors::createAlignedStore(IRBuilder<> &Builder, Value *Val,
|
auto AlignVectors::createAlignedStore(IRBuilder<> &Builder, Value *Val,
|
||||||
|
@ -72,8 +72,8 @@ static Instruction *simplifyX86MaskedLoad(IntrinsicInst &II, InstCombiner &IC) {
|
|||||||
Value *PtrCast = IC.Builder.CreateBitCast(Ptr, VecPtrTy, "castvec");
|
Value *PtrCast = IC.Builder.CreateBitCast(Ptr, VecPtrTy, "castvec");
|
||||||
|
|
||||||
// The pass-through vector for an x86 masked load is a zero vector.
|
// The pass-through vector for an x86 masked load is a zero vector.
|
||||||
CallInst *NewMaskedLoad =
|
CallInst *NewMaskedLoad = IC.Builder.CreateMaskedLoad(
|
||||||
IC.Builder.CreateMaskedLoad(PtrCast, Align(1), BoolMask, ZeroVec);
|
II.getType(), PtrCast, Align(1), BoolMask, ZeroVec);
|
||||||
return IC.replaceInstUsesWith(II, NewMaskedLoad);
|
return IC.replaceInstUsesWith(II, NewMaskedLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3117,7 +3117,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
if (PropagateShadow) {
|
if (PropagateShadow) {
|
||||||
std::tie(ShadowPtr, OriginPtr) =
|
std::tie(ShadowPtr, OriginPtr) =
|
||||||
getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
|
getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
|
||||||
setShadow(&I, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
|
setShadow(&I, IRB.CreateMaskedLoad(ShadowTy, ShadowPtr, Alignment, Mask,
|
||||||
getShadow(PassThru), "_msmaskedld"));
|
getShadow(PassThru), "_msmaskedld"));
|
||||||
} else {
|
} else {
|
||||||
setShadow(&I, getCleanShadow(&I));
|
setShadow(&I, getCleanShadow(&I));
|
||||||
|
@ -2778,7 +2778,7 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
|
|||||||
: ShuffledMask;
|
: ShuffledMask;
|
||||||
}
|
}
|
||||||
NewLoad =
|
NewLoad =
|
||||||
Builder.CreateMaskedLoad(AddrParts[Part], Group->getAlign(),
|
Builder.CreateMaskedLoad(VecTy, AddrParts[Part], Group->getAlign(),
|
||||||
GroupMask, PoisonVec, "wide.masked.vec");
|
GroupMask, PoisonVec, "wide.masked.vec");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2990,15 +2990,15 @@ void InnerLoopVectorizer::vectorizeMemoryInstruction(
|
|||||||
if (CreateGatherScatter) {
|
if (CreateGatherScatter) {
|
||||||
Value *MaskPart = isMaskRequired ? BlockInMaskParts[Part] : nullptr;
|
Value *MaskPart = isMaskRequired ? BlockInMaskParts[Part] : nullptr;
|
||||||
Value *VectorGep = State.get(Addr, Part);
|
Value *VectorGep = State.get(Addr, Part);
|
||||||
NewLI = Builder.CreateMaskedGather(VectorGep, Alignment, MaskPart,
|
NewLI = Builder.CreateMaskedGather(DataTy, VectorGep, Alignment, MaskPart,
|
||||||
nullptr, "wide.masked.gather");
|
nullptr, "wide.masked.gather");
|
||||||
addMetadata(NewLI, LI);
|
addMetadata(NewLI, LI);
|
||||||
} else {
|
} else {
|
||||||
auto *VecPtr = CreateVecPtr(Part, State.get(Addr, VPIteration(0, 0)));
|
auto *VecPtr = CreateVecPtr(Part, State.get(Addr, VPIteration(0, 0)));
|
||||||
if (isMaskRequired)
|
if (isMaskRequired)
|
||||||
NewLI = Builder.CreateMaskedLoad(
|
NewLI = Builder.CreateMaskedLoad(
|
||||||
VecPtr, Alignment, BlockInMaskParts[Part], PoisonValue::get(DataTy),
|
DataTy, VecPtr, Alignment, BlockInMaskParts[Part],
|
||||||
"wide.masked.load");
|
PoisonValue::get(DataTy), "wide.masked.load");
|
||||||
else
|
else
|
||||||
NewLI =
|
NewLI =
|
||||||
Builder.CreateAlignedLoad(DataTy, VecPtr, Alignment, "wide.load");
|
Builder.CreateAlignedLoad(DataTy, VecPtr, Alignment, "wide.load");
|
||||||
|
@ -5403,7 +5403,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
|
|||||||
for (Value *V : E->Scalars)
|
for (Value *V : E->Scalars)
|
||||||
CommonAlignment =
|
CommonAlignment =
|
||||||
commonAlignment(CommonAlignment, cast<LoadInst>(V)->getAlign());
|
commonAlignment(CommonAlignment, cast<LoadInst>(V)->getAlign());
|
||||||
NewLI = Builder.CreateMaskedGather(VecPtr, CommonAlignment);
|
NewLI = Builder.CreateMaskedGather(VecTy, VecPtr, CommonAlignment);
|
||||||
}
|
}
|
||||||
Value *V = propagateMetadata(NewLI, E->Scalars);
|
Value *V = propagateMetadata(NewLI, E->Scalars);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user