[llvm] [LV] Teach LoopVectorizationLegality about struct vector calls (PR #119221)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 14:12:30 PST 2025
================
@@ -942,11 +954,25 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
if (CI && !VFDatabase::getMappings(*CI).empty())
VecCallVariantsFound = true;
+ auto CanWidenInstruction = [this](Instruction const &Inst) {
+ Type *InstTy = Inst.getType();
+ if (isa<StructType>(InstTy)) {
+ if (!isa<CallInst>(Inst) || !canWidenCallReturnType(InstTy))
+ return false;
+ // 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 canVectorizeTy(InstTy);
+ };
+
// 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 ((!VectorType::isValidElementType(I.getType()) &&
- !I.getType()->isVoidTy()) ||
+ if (!CanWidenInstruction(I) ||
----------------
fhahn wrote:
`CanWidenInstruction` -> `CanWidenInstructionTy` as this only focuses on the types, and there are other checks below for checking if we can widen the instruction?
https://github.com/llvm/llvm-project/pull/119221
More information about the llvm-commits
mailing list