Skip to content

[RISCV] Remove fixed vector constraint on masked interleave costing #150624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

preames
Copy link
Collaborator

@preames preames commented Jul 25, 2025

The last of the fixed vector changes for interleaves with masked loads and stores landed last night, so we no longer need the restriction.

Note that our costing in LV will nearly always prefer a scalable type, so this is pretty invisible in practice. All the lowering paths are tested directly.

The last of the fixed vector changes for interleaves with masked
loads and stores landed last night, so we no longer need the
restriction.
@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Philip Reames (preames)

Changes

The last of the fixed vector changes for interleaves with masked loads and stores landed last night, so we no longer need the restriction.

Note that our costing in LV will nearly always prefer a scalable type, so this is pretty invisible in practice. All the lowering paths are tested directly.


Full diff: https://github.com/llvm/llvm-project/pull/150624.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp (+1-3)
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 1624f12a102e3..4899cfdc04fd0 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -983,9 +983,7 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
   // with an adjacent appropriate memory to vlseg/vsseg intrinsics. vlseg/vsseg
   // only support masking per-iteration (i.e. condition), not per-segment (i.e.
   // gap).
-  // TODO: Support masked interleaved access for fixed length vector.
-  if ((isa<ScalableVectorType>(VecTy) || !UseMaskForCond) && !UseMaskForGaps &&
-      Factor <= TLI->getMaxSupportedInterleaveFactor()) {
+  if (!UseMaskForGaps && Factor <= TLI->getMaxSupportedInterleaveFactor()) {
     auto *VTy = cast<VectorType>(VecTy);
     std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(VTy);
     // Need to make sure type has't been scalarized

Copy link
Contributor

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Mel-Chen added a commit to Mel-Chen/llvm-project that referenced this pull request Aug 4, 2025
@Mel-Chen
Copy link
Contributor

Mel-Chen commented Aug 5, 2025

@preames #151665 (comment)
@lukel97 and me plan to enable both fixed- and scalable-width masked interleave access support in #151665. Let me know if you think that's not appropriate. :)

@lukel97
Copy link
Contributor

lukel97 commented Aug 5, 2025

@preames #151665 (comment) @lukel97 and me plan to enable both fixed- and scalable-width masked interleave access support in #151665. Let me know if you think that's not appropriate. :)

Philip's out of office this week, I think you can just go ahead and land #151665 and add him as co-author if you want

@Mel-Chen
Copy link
Contributor

Mel-Chen commented Aug 5, 2025

@preames #151665 (comment) @lukel97 and me plan to enable both fixed- and scalable-width masked interleave access support in #151665. Let me know if you think that's not appropriate. :)

Philip's out of office this week, I think you can just go ahead and land #151665 and add him as co-author if you want

I see, thanks.

Mel-Chen added a commit that referenced this pull request Aug 5, 2025
Now that support for masked loads/stores of interleave groups has
landed, we can enable the loop vectorizer to generate masked interleave
access where applicable.

This improves vectorization in several ways:
* Internal predication support: This enables interleave group
vectorization for loops with internal control flow predication, provided
all members of the group share the same predicate. Gaps in interleave
groups are still not efficiently handled by masking, so masking for gaps
remains disabled for now.
* Tail folding: This allows tail folding of loops with interleave groups
by using masking. Without this, vectorized loops with interleaves would
fall back to using separate gather/scatter accesses, which can be
significantly less efficient.

"[RISCV][TTI] Enable masked interleave access for scalable vector
(#149981)" was reverted by 5294793 due
to triggering an assertion. The issue has been addressed in the patch
"[LV] Fix gap mask requirement for interleaved access (#151105)". On the
other hand, this patch also enable fixed-length masked interleave access
(#150624) since support for fixed-length has also been landed
992118c.

---------

Co-authored-by: Philip Reames <[email protected]>
@preames
Copy link
Collaborator Author

preames commented Aug 7, 2025

I see, thanks.

Yep, totally fine. Thanks!

@preames preames closed this Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants