Skip to content

Commit f6749d8

Browse files
committed
[SLP]Consider unsigned nodes, feeding into sitofp, being converted using
uitofp. Need to use uitofp for unsigned nodes, which are part of minbitwidth analysis, to correctly handle signedness info.
1 parent f0ea888 commit f6749d8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9020,6 +9020,9 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
90209020
VecOpcode =
90219021
SrcIt->second.second ? Instruction::SExt : Instruction::ZExt;
90229022
}
9023+
} else if (VecOpcode == Instruction::SIToFP && SrcIt != MinBWs.end() &&
9024+
!SrcIt->second.second) {
9025+
VecOpcode = Instruction::UIToFP;
90239026
}
90249027
auto GetScalarCost = [&](unsigned Idx) -> InstructionCost {
90259028
auto *VI = cast<Instruction>(UniqueValues[Idx]);
@@ -12398,6 +12401,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1239812401
VecOpcode =
1239912402
SrcIt->second.second ? Instruction::SExt : Instruction::ZExt;
1240012403
}
12404+
} else if (VecOpcode == Instruction::SIToFP && SrcIt != MinBWs.end() &&
12405+
!SrcIt->second.second) {
12406+
VecOpcode = Instruction::UIToFP;
1240112407
}
1240212408
Value *V = (VecOpcode != ShuffleOrOp && VecOpcode == Instruction::BitCast)
1240312409
? InVec

llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define void @foo(ptr %ptr) {
88
; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 334
99
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i16>, ptr [[GEP0]], align 8
1010
; CHECK-NEXT: [[TMP3:%.*]] = xor <2 x i16> [[TMP1]], <i16 -1, i16 -1>
11-
; CHECK-NEXT: [[TMP4:%.*]] = sitofp <2 x i16> [[TMP3]] to <2 x double>
11+
; CHECK-NEXT: [[TMP4:%.*]] = uitofp <2 x i16> [[TMP3]] to <2 x double>
1212
; CHECK-NEXT: [[TMP5:%.*]] = load <2 x i16>, ptr [[GEP3]], align 2
1313
; CHECK-NEXT: [[TMP6:%.*]] = zext <2 x i16> [[TMP5]] to <2 x i32>
1414
; CHECK-NEXT: [[TMP2:%.*]] = zext <2 x i16> [[TMP1]] to <2 x i32>

0 commit comments

Comments
 (0)