[llvm] f6749d8 - [SLP]Consider unsigned nodes, feeding into sitofp, being converted using
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 10:43:15 PDT 2024
Author: Alexey Bataev
Date: 2024-04-11T10:39:54-07:00
New Revision: f6749d8dcb9af5c30affd259f4c4160c54606d91
URL: https://github.com/llvm/llvm-project/commit/f6749d8dcb9af5c30affd259f4c4160c54606d91
DIFF: https://github.com/llvm/llvm-project/commit/f6749d8dcb9af5c30affd259f4c4160c54606d91.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4ac719af602959..2995cb8435f769 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9020,6 +9020,9 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
VecOpcode =
SrcIt->second.second ? Instruction::SExt : Instruction::ZExt;
}
+ } else if (VecOpcode == Instruction::SIToFP && SrcIt != MinBWs.end() &&
+ !SrcIt->second.second) {
+ VecOpcode = Instruction::UIToFP;
}
auto GetScalarCost = [&](unsigned Idx) -> InstructionCost {
auto *VI = cast<Instruction>(UniqueValues[Idx]);
@@ -12398,6 +12401,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
VecOpcode =
SrcIt->second.second ? Instruction::SExt : Instruction::ZExt;
}
+ } else if (VecOpcode == Instruction::SIToFP && SrcIt != MinBWs.end() &&
+ !SrcIt->second.second) {
+ VecOpcode = Instruction::UIToFP;
}
Value *V = (VecOpcode != ShuffleOrOp && VecOpcode == Instruction::BitCast)
? InVec
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll b/llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll
index 00dd9b7e6fb479..a0e17446b6abb1 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/sitofp-minbitwidth-node.ll
@@ -8,7 +8,7 @@ define void @foo(ptr %ptr) {
; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 334
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i16>, ptr [[GEP0]], align 8
; CHECK-NEXT: [[TMP3:%.*]] = xor <2 x i16> [[TMP1]], <i16 -1, i16 -1>
-; CHECK-NEXT: [[TMP4:%.*]] = sitofp <2 x i16> [[TMP3]] to <2 x double>
+; CHECK-NEXT: [[TMP4:%.*]] = uitofp <2 x i16> [[TMP3]] to <2 x double>
; CHECK-NEXT: [[TMP5:%.*]] = load <2 x i16>, ptr [[GEP3]], align 2
; CHECK-NEXT: [[TMP6:%.*]] = zext <2 x i16> [[TMP5]] to <2 x i32>
; CHECK-NEXT: [[TMP2:%.*]] = zext <2 x i16> [[TMP1]] to <2 x i32>
More information about the llvm-commits
mailing list