[llvm] [LV][REVEC] Initial support for re-vectorisation (PR #208213)
Gaƫtan Bossu via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 03:56:47 PDT 2026
================
@@ -1739,8 +1739,19 @@ void VPInstruction::execute(VPTransformState &State) {
if (!hasResult())
return;
assert(GeneratedValue && "generate must produce a value");
- assert(((GeneratedValue->getType()->isVectorTy() ||
- GeneratedValue->getType()->isStructTy()) == !GenerateSingleScalar) &&
+ // Figure out whether the initial type got widened, i.e. a scalar type became
+ // a vector, or a vector got widened to a wider EC for REVEC. It isn't enough
+ // to check that the new EC is larger, as VFScaleFactor can cause vectors to
+ // have a single element.
+ Type *InitialTy = getScalarType();
+ Type *NewTy = GeneratedValue->getType();
+ ElementCount InitialEC = getElementCount(InitialTy);
+ ElementCount NewEC = getElementCount(NewTy);
+ bool GotWidened = ElementCount::isKnownGT(NewEC, InitialEC) ||
+ (NewEC.isScalable() && !InitialEC.isScalable()) ||
+ (NewTy->isVectorTy() && !InitialTy->isVectorTy()) ||
+ NewTy->isStructTy();
----------------
gbossu wrote:
Now that having a vector type does not mean "something got widened/vectorised" anymore, computing `GotWidened` isn't all that trivial.
@artagnon, I see you did some work to bring additional semantics to VPinstructions in https://github.com/llvm/llvm-project/pull/196207. Maybe you have some thoughts on how to rewrite that assert more clearly?
https://github.com/llvm/llvm-project/pull/208213
More information about the llvm-commits
mailing list