[llvm] 9959cdb - [IRBUilder] Introduce getAllOnesMask [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 10:54:14 PDT 2023
Author: Philip Reames
Date: 2023-06-05T10:54:07-07:00
New Revision: 9959cdb66a02b50e29f4635b65c59a422f7b11c7
URL: https://github.com/llvm/llvm-project/commit/9959cdb66a02b50e29f4635b65c59a422f7b11c7
DIFF: https://github.com/llvm/llvm-project/commit/9959cdb66a02b50e29f4635b65c59a422f7b11c7.diff
LOG: [IRBUilder] Introduce getAllOnesMask [nfc]
Simplify D99750 by factoring out a utility which we already have multiple instances of in tree.
Added:
Modified:
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/IRBuilder.cpp
llvm/lib/IR/VectorBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 7cc6597211322..1e32908dd5373 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -800,6 +800,12 @@ class IRBuilderBase {
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.
///
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index f3d5a6099cd60..fd5a00f7d4786 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -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};
diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp
index e7be7a98a593c..c07bc0561fba9 100644
--- a/llvm/lib/IR/VectorBuilder.cpp
+++ b/llvm/lib/IR/VectorBuilder.cpp
@@ -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() {
More information about the llvm-commits
mailing list