Skip to content

Commit 7643c8a

Browse files
committed
address Tex's PR comments
1 parent 1c85070 commit 7643c8a

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ bool isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
154154
/// the operand at index \p OpdIdx, or on the return type if \p OpdIdx is -1.
155155
bool isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx);
156156

157+
/// Identifies if the vector form of the intrinsic that returns a struct is
158+
/// overloaded at the struct element index \p RetIdx.
159+
bool isVectorIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID,
160+
int RetIdx);
161+
157162
/// Returns intrinsic ID for call.
158163
/// For the input call instruction it finds mapping intrinsic and returns
159164
/// its intrinsic ID, in case it does not found it return not_intrinsic.

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
152152
}
153153
}
154154

155+
bool llvm::isVectorIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID,
156+
int RetIdx) {
157+
switch (ID) {
158+
case Intrinsic::frexp:
159+
return RetIdx == 0 || RetIdx == 1;
160+
default:
161+
return RetIdx == 0;
162+
}
163+
}
164+
155165
/// Returns intrinsic ID for call.
156166
/// For the input call instruction it finds mapping intrinsic and returns
157167
/// its ID, in case it does not found it return not_intrinsic.

llvm/lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
700700
/// element if possible for the intrinsic.
701701
bool ScalarizerVisitor::splitCall(CallInst &CI) {
702702
Type *CallType = CI.getType();
703-
bool AreAllMatchingVectors = isStructOfMatchingFixedVectors(CallType);
703+
bool AreAllVectorsOfMatchingSize = isStructOfMatchingFixedVectors(CallType);
704704
std::optional<VectorSplit> VS;
705-
if (AreAllMatchingVectors)
705+
if (AreAllVectorsOfMatchingSize)
706706
VS = getVectorSplit(CallType->getContainedType(0));
707707
else
708708
VS = getVectorSplit(CallType);
@@ -730,19 +730,17 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
730730
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, -1))
731731
Tys.push_back(VS->SplitTy);
732732

733-
if (AreAllMatchingVectors) {
734-
Type *PrevType = CallType->getContainedType(0);
733+
if (AreAllVectorsOfMatchingSize) {
735734
for (unsigned I = 1; I < CallType->getNumContainedTypes(); I++) {
736-
Type *CurrType = cast<FixedVectorType>(CallType->getContainedType(I));
737-
if (PrevType != CurrType) {
738-
std::optional<VectorSplit> CurrVS = getVectorSplit(CurrType);
735+
if (isVectorIntrinsicWithStructReturnOverloadAtField(ID, I)) {
736+
std::optional<VectorSplit> CurrVS = getVectorSplit(
737+
cast<FixedVectorType>(CallType->getContainedType(I)));
739738
// This case does not seem to happen, but it is possible for
740739
// VectorSplit.NumPacked >= NumElems. If that happens a VectorSplit
741740
// is not returned and we will bailout of handling this call.
742741
if (!CurrVS)
743742
return false;
744743
Tys.push_back(CurrVS->SplitTy);
745-
PrevType = CurrType;
746744
}
747745
}
748746
}

0 commit comments

Comments
 (0)