aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-05-15 22:19:36 +0100
committerFlorian Hahn <flo@fhahn.com>2025-05-15 22:19:36 +0100
commitefae492ad1ba80764ec4a85f5622a8713646f970 (patch)
tree8dea050d6701f8fd958caa3c8b9f03880284c966 /llvm/lib/Transforms
parent090f46d8d246762401c41c5486dde299382d6c90 (diff)
downloadllvm-efae492ad1ba80764ec4a85f5622a8713646f970.zip
llvm-efae492ad1ba80764ec4a85f5622a8713646f970.tar.gz
llvm-efae492ad1ba80764ec4a85f5622a8713646f970.tar.bz2
[VPlan] Add VPTypeAnalysis constructor taking a VPlan (NFC).
Add constructor that retrieves the scalar type from the trip count expression, if no canonical IV is available. Used in the verifier, in preparation for late verification, when the canonical IV has been dissolved.
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp20
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanAnalysis.h2
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp3
3 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index c86815c..b07f9a3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -20,6 +20,26 @@ using namespace llvm;
#define DEBUG_TYPE "vplan"
+VPTypeAnalysis::VPTypeAnalysis(const VPlan &Plan)
+ : Ctx(Plan.getScalarHeader()->getIRBasicBlock()->getContext()) {
+ if (auto LoopRegion = Plan.getVectorLoopRegion()) {
+ if (const auto *CanIV = dyn_cast<VPCanonicalIVPHIRecipe>(
+ &LoopRegion->getEntryBasicBlock()->front())) {
+ CanonicalIVTy = CanIV->getScalarType();
+ return;
+ }
+ }
+
+ // If there's no canonical IV, retrieve the type from the trip count
+ // expression.
+ auto *TC = Plan.getTripCount();
+ if (TC->isLiveIn()) {
+ CanonicalIVTy = TC->getLiveInIRValue()->getType();
+ return;
+ }
+ CanonicalIVTy = cast<VPExpandSCEVRecipe>(TC)->getSCEV()->getType();
+}
+
Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPBlendRecipe *R) {
Type *ResTy = inferScalarType(R->getIncomingValue(0));
for (unsigned I = 1, E = R->getNumIncomingValues(); I != E; ++I) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.h b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.h
index cc21870..941e139 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.h
@@ -58,6 +58,8 @@ public:
VPTypeAnalysis(Type *CanonicalIVTy)
: CanonicalIVTy(CanonicalIVTy), Ctx(CanonicalIVTy->getContext()) {}
+ VPTypeAnalysis(const VPlan &Plan);
+
/// Infer the type of \p V. Returns the scalar type of \p V.
Type *inferScalarType(const VPValue *V);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
index 1e7e039..75fc763 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -455,8 +455,7 @@ bool VPlanVerifier::verify(const VPlan &Plan) {
bool llvm::verifyVPlanIsValid(const VPlan &Plan) {
VPDominatorTree VPDT;
VPDT.recalculate(const_cast<VPlan &>(Plan));
- VPTypeAnalysis TypeInfo(
- const_cast<VPlan &>(Plan).getCanonicalIV()->getScalarType());
+ VPTypeAnalysis TypeInfo(Plan);
VPlanVerifier Verifier(VPDT, TypeInfo);
return Verifier.verify(Plan);
}