[llvm] [LV] Teach LoopVectorizationLegality about struct vector calls (PR #119221)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 02:03:51 PST 2025


================
@@ -942,11 +954,24 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
       if (CI && !VFDatabase::getMappings(*CI).empty())
         VecCallVariantsFound = true;
 
+      auto CanWidenInstruction = [this](Instruction const &Inst) {
+        Type *InstTy = Inst.getType();
+        if (isa<CallInst>(Inst) && isa<StructType>(InstTy) &&
+            canWidenCallReturnType(InstTy)) {
+          // TODO: Remove the `StructVecCallFound` flag once vectorizing calls
+          // with struct returns is supported.
+          StructVecCallFound = true;
+          // For now, we only recognize struct values returned from calls where
+          // all users are extractvalue as vectorizable.
+          return all_of(Inst.users(), IsaPred<ExtractValueInst>);
+        }
+        return VectorType::isValidElementType(InstTy) || InstTy->isVoidTy();
----------------
MacDue wrote:

Sure, reworked this a little to use `canVectorizeTy()` :+1: 

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


More information about the llvm-commits mailing list