[llvm] [LV] Add initial support for vectorizing literal struct return values (PR #109833)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 08:58:19 PST 2024
================
@@ -943,11 +943,23 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
if (CI && !VFDatabase::getMappings(*CI).empty())
VecCallVariantsFound = true;
+ auto canWidenInstruction = [](Instruction const & Inst) {
+ Type *InstTy = Inst.getType();
+ if (isa<CallInst>(Inst) && isa<StructType>(InstTy) &&
+ canWidenType(InstTy)) {
+ // For now, we can only widen struct values returned from calls where
+ // all users are extractvalue instructions.
+ return llvm::all_of(Inst.uses(), [](auto &Use) {
+ return isa<ExtractValueInst>(Use.getUser());
+ });
+ }
+ return VectorType::isValidElementType(InstTy) || InstTy->isVoidTy();
+ };
+
// 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.
- Type *InstTy = I.getType();
- if (!(InstTy->isVoidTy() || canWidenType(InstTy)) ||
+ if (!canWidenInstruction(I) ||
----------------
MacDue wrote:
Why? I find having the helper return `true` when it can widen a little clearer
https://github.com/llvm/llvm-project/pull/109833
More information about the llvm-commits
mailing list