Skip to content

Commit af468f3

Browse files
Cleanup: addressing review.
1 parent 83dad82 commit af468f3

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ void getVectorVariantNames(const CallInst &CI,
200200
/// TargetLibraryInfo. It uses \p ScalarFTy for the types, and \p Info to get
201201
/// the vectorization factor and whether a particular parameter is indeed a
202202
/// vector, since some of them may be scalars.
203-
std::optional<FunctionType *> createFunctionType(const VFInfo &Info,
204-
const FunctionType *ScalarFTy);
203+
FunctionType *createFunctionType(const VFInfo &Info,
204+
const FunctionType *ScalarFTy);
205205
} // end namespace VFABI
206206

207207
/// The Vector Function Database.

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,8 @@ void VFABI::getVectorVariantNames(
14801480
}
14811481
}
14821482

1483-
std::optional<FunctionType *>
1484-
VFABI::createFunctionType(const VFInfo &Info, const FunctionType *ScalarFTy) {
1483+
FunctionType *VFABI::createFunctionType(const VFInfo &Info,
1484+
const FunctionType *ScalarFTy) {
14851485
ElementCount VF = Info.Shape.VF;
14861486
// Create vector parameter types
14871487
SmallVector<Type *, 8> VecTypes;
@@ -1493,22 +1493,17 @@ VFABI::createFunctionType(const VFInfo &Info, const FunctionType *ScalarFTy) {
14931493
}
14941494

14951495
// Get mask's position mask and append one if not present in the Instruction.
1496-
int MaskPos = -1;
1497-
if (Info.isMasked()) {
1498-
auto OptMaskPos = Info.getParamIndexForOptionalMask();
1496+
if (auto OptMaskPos = Info.getParamIndexForOptionalMask()) {
14991497
if (!OptMaskPos)
1500-
return std::nullopt;
1501-
1502-
MaskPos = OptMaskPos.value();
1498+
return nullptr;
15031499
VectorType *MaskTy =
15041500
VectorType::get(Type::getInt1Ty(ScalarFTy->getContext()), VF);
1505-
VecTypes.insert(VecTypes.begin() + MaskPos, MaskTy);
1501+
VecTypes.insert(VecTypes.begin() + OptMaskPos.value(), MaskTy);
15061502
}
15071503
auto *RetTy = ScalarFTy->getReturnType();
15081504
if (!RetTy->isVoidTy())
15091505
RetTy = VectorType::get(ScalarFTy->getReturnType(), VF);
1510-
FunctionType *VecFTy = FunctionType::get(RetTy, VecTypes, false);
1511-
return VecFTy;
1506+
return FunctionType::get(RetTy, VecTypes, false);
15121507
}
15131508

15141509
bool VFShape::hasValidParameterList() const {

llvm/unittests/Analysis/VectorFunctionABITest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,10 @@ class VFABIParserTest : public ::testing::Test {
126126

127127
// Use VFInfo and the mock CallInst to create a FunctionType that will
128128
// include a mask when relevant.
129-
auto OptVecFTy = VFABI::createFunctionType(Info, ScalarFTy);
130-
if (!OptVecFTy)
129+
FunctionType *VecFTy = VFABI::createFunctionType(Info, ScalarFTy);
130+
if (!VecFTy)
131131
return false;
132132

133-
FunctionType *VecFTy = *OptVecFTy;
134133
// Check that vectorized parameters' size match with VFInfo.
135134
// Both may include a mask.
136135
if ((VecFTy->getNumParams() != Info.Shape.Parameters.size()))

0 commit comments

Comments
 (0)