@@ -104,37 +104,31 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
104
104
// a void type.
105
105
auto *VTy = dyn_cast<VectorType>(II->getType ());
106
106
ElementCount EC (VTy ? VTy->getElementCount () : ElementCount::getFixed (0 ));
107
+ Type *ScalarRetTy = II->getType ()->getScalarType ();
107
108
// Compute the argument types of the corresponding scalar call and check that
108
109
// all vector operands match the previously found EC.
109
110
SmallVector<Type *, 8 > ScalarArgTypes;
110
111
Intrinsic::ID IID = II->getIntrinsicID ();
111
112
112
113
// OloadTys collects types used in scalar intrinsic overload name.
113
114
SmallVector<Type *, 3 > OloadTys;
114
- if (VTy && isVectorIntrinsicWithOverloadTypeAtArg (IID, -1 ))
115
- OloadTys.push_back (VTy-> getElementType () );
115
+ if (isVectorIntrinsicWithOverloadTypeAtArg (IID, -1 ))
116
+ OloadTys.push_back (ScalarRetTy );
116
117
117
118
for (auto Arg : enumerate(II->args ())) {
118
119
auto *ArgTy = Arg.value ()->getType ();
119
- // Gather type if it is used in the overload name.
120
- if (isVectorIntrinsicWithOverloadTypeAtArg (IID, Arg.index ())) {
121
- if (!isVectorIntrinsicWithScalarOpAtArg (IID, Arg.index ()) && isa<VectorType>(ArgTy))
122
- OloadTys.push_back (cast<VectorType>(ArgTy)->getElementType ());
123
- else
124
- OloadTys.push_back (ArgTy);
125
- }
126
-
127
- if (isVectorIntrinsicWithScalarOpAtArg (IID, Arg.index ())) {
128
- ScalarArgTypes.push_back (ArgTy);
129
- } else if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
130
- ScalarArgTypes.push_back (VectorArgTy->getElementType ());
120
+ auto *ScalarArgTy = ArgTy->getScalarType ();
121
+ ScalarArgTypes.push_back (ScalarArgTy);
122
+ if (isVectorIntrinsicWithOverloadTypeAtArg (IID, Arg.index ()))
123
+ OloadTys.push_back (ScalarArgTy);
124
+ if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
131
125
// When return type is void, set EC to the first vector argument, and
132
126
// disallow vector arguments with different ECs.
133
127
if (EC.isZero ())
134
128
EC = VectorArgTy->getElementCount ();
135
129
else if (EC != VectorArgTy->getElementCount ())
136
130
return false ;
137
- } else
131
+ } else if (! isVectorIntrinsicWithScalarOpAtArg (IID, Arg. index ()))
138
132
// Exit when it is supposed to be a vector argument but it isn't.
139
133
return false ;
140
134
}
@@ -160,7 +154,6 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
160
154
161
155
// Replace the call to the intrinsic with a call to the vector library
162
156
// function.
163
- Type *ScalarRetTy = II->getType ()->getScalarType ();
164
157
FunctionType *ScalarFTy =
165
158
FunctionType::get (ScalarRetTy, ScalarArgTypes, /* isVarArg*/ false );
166
159
const std::string MangledName = VD->getVectorFunctionABIVariantString ();
0 commit comments