[llvm] [LV] Convert uniform-address unmasked scatters to scalar store. (PR #166114)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 02:28:04 PST 2025
================
@@ -1400,14 +1400,46 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
vp_depth_first_shallow(Plan.getVectorLoopRegion()->getEntry()))) {
for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {
- if (!isa<VPWidenRecipe, VPWidenSelectRecipe, VPReplicateRecipe>(&R))
+ if (!isa<VPWidenRecipe, VPWidenSelectRecipe, VPReplicateRecipe,
+ VPWidenStoreRecipe>(&R))
continue;
auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
if (RepR && (RepR->isSingleScalar() || RepR->isPredicated()))
continue;
- auto *RepOrWidenR = cast<VPSingleDefRecipe>(&R);
- if (RepR && isa<StoreInst>(RepR->getUnderlyingInstr()) &&
+ // Convert scatters with a uniform address that is unmasked into an
+ // extract-last-element + scalar store.
+ // TODO: Add a profitability check comparing the cost of a scatter vs.
+ // extract + scalar store.
+ auto *WidenStoreR = dyn_cast<VPWidenStoreRecipe>(&R);
+ if (WidenStoreR && vputils::isSingleScalar(WidenStoreR->getAddr()) &&
----------------
fhahn wrote:
Is the reason we create a scatter initial, but can simplify it here due to some other VPlan transformation?
https://github.com/llvm/llvm-project/pull/166114
More information about the llvm-commits
mailing list