Skip to content

Commit 628f983

Browse files
committed
review comments:
- consolidate the usage of isVectorIntrinsicWithOverloadTypeAtArg into one place of VectorUtils.cppp
1 parent 58925a4 commit 628f983

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ bool isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
152152

153153
/// Identifies if the vector form of the intrinsic is overloaded on the type of
154154
/// the operand at index \p OpdIdx, or on the return type if \p OpdIdx is -1.
155-
bool isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx);
155+
bool isVectorIntrinsicWithOverloadTypeAtArg(
156+
Intrinsic::ID ID, int OpdIdx, const TargetTransformInfo *TTI = nullptr);
156157

157158
/// Identifies if the vector form of the intrinsic that returns a struct is
158159
/// overloaded at the struct element index \p RetIdx.

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,13 @@ bool llvm::isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
131131
}
132132
}
133133

134-
bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
135-
int OpdIdx) {
134+
bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(
135+
Intrinsic::ID ID, int OpdIdx, const TargetTransformInfo *TTI) {
136136
assert(ID != Intrinsic::not_intrinsic && "Not an intrinsic!");
137137

138+
if (TTI && Intrinsic::isTargetIntrinsic(ID))
139+
return TTI->isVectorIntrinsicWithOverloadTypeAtArg(ID, OpdIdx);
140+
138141
switch (ID) {
139142
case Intrinsic::fptosi_sat:
140143
case Intrinsic::fptoui_sat:

llvm/lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
280280
bool visit(Function &F);
281281

282282
bool isTriviallyScalarizable(Intrinsic::ID ID);
283-
bool isIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int ScalarOpdIdx);
284283

285284
// InstVisitor methods. They return true if the instruction was scalarized,
286285
// false if nothing changed.
@@ -697,13 +696,6 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
697696
TTI->isTargetIntrinsicTriviallyScalarizable(ID);
698697
}
699698

700-
bool ScalarizerVisitor::isIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
701-
int ScalarOpdIdx) {
702-
return Intrinsic::isTargetIntrinsic(ID)
703-
? TTI->isVectorIntrinsicWithOverloadTypeAtArg(ID, ScalarOpdIdx)
704-
: isVectorIntrinsicWithOverloadTypeAtArg(ID, ScalarOpdIdx);
705-
}
706-
707699
/// If a call to a vector typed intrinsic function, split into a scalar call per
708700
/// element if possible for the intrinsic.
709701
bool ScalarizerVisitor::splitCall(CallInst &CI) {
@@ -735,7 +727,7 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
735727

736728
SmallVector<llvm::Type *, 3> Tys;
737729
// Add return type if intrinsic is overloaded on it.
738-
if (isIntrinsicWithOverloadTypeAtArg(ID, -1))
730+
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, -1, TTI))
739731
Tys.push_back(VS->SplitTy);
740732

741733
if (AreAllVectorsOfMatchingSize) {
@@ -775,13 +767,13 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
775767
}
776768

777769
Scattered[I] = scatter(&CI, OpI, *OpVS);
778-
if (isIntrinsicWithOverloadTypeAtArg(ID, I)) {
770+
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I, TTI)) {
779771
OverloadIdx[I] = Tys.size();
780772
Tys.push_back(OpVS->SplitTy);
781773
}
782774
} else {
783775
ScalarOperands[I] = OpI;
784-
if (isIntrinsicWithOverloadTypeAtArg(ID, I))
776+
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I, TTI))
785777
Tys.push_back(OpI->getType());
786778
}
787779
}

0 commit comments

Comments
 (0)