@@ -98,10 +98,9 @@ class VFABIParserTest : public ::testing::Test {
98
98
// / number and type of arguments with both the ScalarFTy and the operands of
99
99
// / the call.
100
100
bool checkFunctionType () {
101
- // Create a mock vectorized CallInst using dummy values and then use it to
102
- // create a vector FunctionType. In the case of scalable ISAs, the created
103
- // vector FunctionType might have a mask parameter Type, however, this input
104
- // CallInst will not have a mask operand.
101
+ // For scalable ISAs, the created vector FunctionType might have a mask
102
+ // parameter Type, according to VFABI. Regardless, this input CallInst,
103
+ // despite being a vectorized call, it will not have a masked operand.
105
104
SmallVector<Value *, 8 > Args;
106
105
SmallVector<Type *, 8 > CallTypes;
107
106
for (auto [VFParam, STy] :
@@ -117,47 +116,21 @@ class VFABIParserTest : public ::testing::Test {
117
116
118
117
// Mangled names do not currently encode return Type information. Generally,
119
118
// return types are vectors, so use one.
120
- Type *RetTy = ScalarFTy->getReturnType ();
121
- if (!RetTy ->isVoidTy ())
122
- RetTy = VectorType::get (RetTy , Info.Shape .VF );
119
+ Type *VecRetTy = ScalarFTy->getReturnType ();
120
+ if (!VecRetTy ->isVoidTy ())
121
+ VecRetTy = VectorType::get (VecRetTy , Info.Shape .VF );
123
122
124
123
FunctionCallee F = M->getOrInsertFunction (
125
- VectorName, FunctionType::get (RetTy , CallTypes, false ));
124
+ VectorName, FunctionType::get (VecRetTy , CallTypes, false ));
126
125
std::unique_ptr<CallInst> CI (CallInst::Create (F, Args));
127
126
128
127
// Use VFInfo and the mock CallInst to create a FunctionType that will
129
- // include a mask where relevant.
130
- auto OptVecFTyPos = VFABI::createFunctionType (Info, CI.get (), M.get ());
128
+ // include a mask when relevant.
129
+ auto OptVecFTyPos =
130
+ VFABI::createFunctionType (Info, ScalarFTy, VecRetTy, M.get ());
131
131
if (!OptVecFTyPos)
132
132
return false ;
133
133
134
- // Ensure that masked Instructions are handled
135
- if (isMasked ()) {
136
- // In case of a masked call, try creating another mock CallInst that is
137
- // masked. createFunctionType should be able to handle this.
138
- SmallVector<Type *, 8 > CallTypesInclMask (CallTypes);
139
- SmallVector<Value *, 8 > ArgsInclMask (Args);
140
- Type *MaskTy = VectorType::get (Type::getInt1Ty (M->getContext ()), VF);
141
- CallTypesInclMask.push_back (MaskTy);
142
- ArgsInclMask.push_back (Constant::getNullValue (MaskTy));
143
-
144
- FunctionCallee FMasked = M->getOrInsertFunction (
145
- VectorName + " _Masked" ,
146
- FunctionType::get (RetTy, CallTypesInclMask, false ));
147
- std::unique_ptr<CallInst> CIMasked (
148
- CallInst::Create (FMasked, ArgsInclMask));
149
- auto OptVecFTyMaskedPos =
150
- VFABI::createFunctionType (Info, CIMasked.get (), M.get ());
151
- if (!OptVecFTyMaskedPos)
152
- return false ;
153
-
154
- // Both FunctionTypes should have the same number of parameters.
155
- assert (
156
- (OptVecFTyPos->first ->getNumParams () ==
157
- OptVecFTyMaskedPos->first ->getNumParams ()) &&
158
- " createFunctionType should accept masked or non masked Instructions" );
159
- }
160
-
161
134
FunctionType *VecFTy = OptVecFTyPos->first ;
162
135
// Check that vectorized parameters' size match with VFInfo.
163
136
// Both may include a mask.
@@ -324,7 +297,7 @@ TEST_F(VFABIParserTest, LinearWithCompileTimeNegativeStep) {
324
297
EXPECT_EQ (ISA, VFISAKind::AdvancedSIMD);
325
298
EXPECT_FALSE (isMasked ());
326
299
EXPECT_TRUE (matchParametersNum ());
327
- EXPECT_FALSE (checkFunctionType ()); // invalid: all operands are scalar
300
+ EXPECT_TRUE (checkFunctionType ());
328
301
EXPECT_EQ (VF, ElementCount::getFixed (2 ));
329
302
EXPECT_EQ (Parameters.size (), (unsigned )4 );
330
303
EXPECT_EQ (Parameters[0 ], VFParameter ({0 , VFParamKind::OMP_Linear, -1 }));
@@ -389,7 +362,7 @@ TEST_F(VFABIParserTest, LinearWithoutCompileTime) {
389
362
EXPECT_EQ (ISA, VFISAKind::AdvancedSIMD);
390
363
EXPECT_FALSE (isMasked ());
391
364
EXPECT_TRUE (matchParametersNum ());
392
- EXPECT_FALSE (checkFunctionType ()); // invalid: all operands are scalar
365
+ EXPECT_TRUE (checkFunctionType ());
393
366
EXPECT_EQ (Parameters.size (), (unsigned )8 );
394
367
EXPECT_EQ (Parameters[0 ], VFParameter ({0 , VFParamKind::OMP_Linear, 1 }));
395
368
EXPECT_EQ (Parameters[1 ], VFParameter ({1 , VFParamKind::OMP_LinearVal, 1 }));
@@ -452,7 +425,7 @@ TEST_F(VFABIParserTest, ParseUniform) {
452
425
EXPECT_EQ (ISA, VFISAKind::AdvancedSIMD);
453
426
EXPECT_FALSE (isMasked ());
454
427
EXPECT_TRUE (matchParametersNum ());
455
- EXPECT_FALSE (checkFunctionType ()); // invalid: all operands are scalar
428
+ EXPECT_TRUE (checkFunctionType ());
456
429
EXPECT_EQ (VF, ElementCount::getFixed (2 ));
457
430
EXPECT_EQ (Parameters.size (), (unsigned )1 );
458
431
EXPECT_EQ (Parameters[0 ], VFParameter ({0 , VFParamKind::OMP_Uniform, 0 }));
0 commit comments