[llvm] [VPlan] Support live-ins without underlying IR in type analysis. (PR #80723)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 02:10:19 PST 2024


================
@@ -203,6 +198,16 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
   llvm_unreachable("Unhandled opcode");
 }
 
+VPTypeAnalysis::VPTypeAnalysis(VPlan &Plan, LLVMContext &Ctx) : Ctx(Ctx) {
+  auto *CanIV = Plan.getCanonicalIV();
+  Type *CanIVTy = inferScalarType(CanIV);
+  CachedTypes[&Plan.getVectorTripCount()] = CanIVTy;
+  CachedTypes[&Plan.getVFxUF()] = CanIVTy;
+  CachedTypes[Plan.getTripCount()] = CanIVTy;
+  if (auto *BTC = Plan.getBackedgeTakenCount())
+    CachedTypes[BTC] = CanIVTy;
----------------
fhahn wrote:

Thanks, updated to take the CanonicalIVType as argument, instead of the whole Plan and avoid caching it as suggested!

The canonical IV type is available once it is added via the type of its start value. Updated patch uses `getCanonicalIV()->getScalarType()` to retrieve that type.

https://github.com/llvm/llvm-project/pull/80723


More information about the llvm-commits mailing list