[llvm] [VPlan] Materialize VF and VFxUF using VPInstructions. (PR #152879)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 03:54:40 PDT 2025


================
@@ -276,6 +276,20 @@ class VPBuilder {
     return tryInsertInstruction(new VPPhi(IncomingValues, DL, Name));
   }
 
+  VPValue *createElementCount(Type *Ty, ElementCount EC) {
+    VPlan &Plan = *getInsertBlock()->getPlan();
+    VPValue *RuntimeEC =
+        Plan.getOrAddLiveIn(ConstantInt::get(Ty, EC.getKnownMinValue()));
+    if (EC.isScalable()) {
+      VPValue *VScale = createNaryOp(VPInstruction::VScale, {}, Ty);
+      RuntimeEC = EC.getKnownMinValue() == 1
+                      ? VScale
+                      : createNaryOp(Instruction::Mul, {VScale, RuntimeEC},
+                                     VPIRFlags::WrapFlagsTy(true, false));
----------------
lukel97 wrote:

Nit, can you use createOverflowingOp here to avoid the WrapFlagsTy constructor? Not sure if it's worth it or not but we seem to have the helper anyway.

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


More information about the llvm-commits mailing list