[IRBUilder] Introduce getAllOnesMask [nfc]

Simplify D99750 by factoring out a utility which we already have multiple instances of in tree.
This commit is contained in:
Philip Reames 2023-06-05 10:46:49 -07:00 committed by Philip Reames
parent ced7e4f53b
commit 9959cdb66a
3 changed files with 9 additions and 7 deletions

View File

@ -800,6 +800,12 @@ public:
CallInst *CreateMaskedCompressStore(Value *Val, Value *Ptr,
Value *Mask = nullptr);
/// Return an all true boolean vector (mask) with \p NumElts lanes.
Value *getAllOnesMask(ElementCount NumElts) {
VectorType *VTy = VectorType::get(Type::getInt1Ty(Context), NumElts);
return Constant::getAllOnesValue(VTy);
}
/// Create an assume intrinsic call that allows the optimizer to
/// assume that the provided condition will be true.
///

View File

@ -661,8 +661,7 @@ CallInst *IRBuilderBase::CreateMaskedGather(Type *Ty, Value *Ptrs,
assert(NumElts == PtrsTy->getElementCount() && "Element count mismatch");
if (!Mask)
Mask = Constant::getAllOnesValue(
VectorType::get(Type::getInt1Ty(Context), NumElts));
Mask = getAllOnesMask(NumElts);
if (!PassThru)
PassThru = PoisonValue::get(Ty);
@ -697,8 +696,7 @@ CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
#endif
if (!Mask)
Mask = Constant::getAllOnesValue(
VectorType::get(Type::getInt1Ty(Context), NumElts));
Mask = getAllOnesMask(NumElts);
Type *OverloadedTypes[] = {DataTy, PtrsTy};
Value *Ops[] = {Data, Ptrs, getInt32(Alignment.value()), Mask};

View File

@ -32,9 +32,7 @@ Module &VectorBuilder::getModule() const {
}
Value *VectorBuilder::getAllTrueMask() {
auto *BoolTy = Builder.getInt1Ty();
auto *MaskTy = VectorType::get(BoolTy, StaticVectorLength);
return ConstantInt::getAllOnesValue(MaskTy);
return Builder.getAllOnesMask(StaticVectorLength);
}
Value &VectorBuilder::requestMask() {