[llvm-branch-commits] [llvm] [LV][REVEC] Initial support for re-vectorisation (PR #208213)

Gaƫtan Bossu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 17 03:41:39 PDT 2026


================
@@ -974,13 +991,19 @@ bool LoopVectorizationLegality::canVectorizeInstr(Instruction &I) {
            all_of(Inst.users(), IsaPred<ExtractValueInst>);
   };
 
+  auto CanWidenCast = [&](const Instruction &CastI) {
+    assert(isa<CastInst>(CastI));
+    assert(CanWidenInstructionTy(CastI) &&
+           "CanWidenInstructionTy was not checked beforehand.");
+    Type *FromTy = CastI.getOperand(0)->getType();
+    return VectorType::isValidElementType(FromTy) ||
+           (isa<FixedVectorType>(FromTy) && VectorizeVectorLoops);
+  };
+
   // Check that the instruction return type is vectorizable.
-  // We can't vectorize casts from vector type to scalar type.
-  // Also, we can't vectorize extractelement instructions.
-  if (!CanWidenInstructionTy(I) ||
-      (isa<CastInst>(I) &&
-       !VectorType::isValidElementType(I.getOperand(0)->getType())) ||
-      isa<ExtractElementInst>(I)) {
+  // Also, we cannot re-vectorize element or shuffle operations yet.
+  if (!CanWidenInstructionTy(I) || (isa<CastInst>(I) && !CanWidenCast(I)) ||
+      isa<ExtractElementInst, InsertElementInst, ShuffleVectorInst>(I)) {
----------------
gbossu wrote:

That intrinsic isn't used to re-vectorise shufflevectors (I'll need a different one for that). Instead it's used to broadcast a vector to a wider one. It is used for "uniform"/livein values. You can find an example in `llvm/test/Transforms/LoopVectorize/revec-livein.ll`

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


More information about the llvm-branch-commits mailing list