Skip to content

Conversation

@wecing
Copy link
Contributor

@wecing wecing commented Nov 7, 2025

We have a private extension which also uses the vector type in the frontend. Our platform does not have the V extension, so it triggered assertion failures from within getLMULCost().

I am not sure what is the best way to handle this, or if there are more such assertions within the codebase. But it feels reasonable to check for V extension before assuming LMUL exists.

We have a private extension which also uses the vector type in the
frontend. Our platform does not have the V extension, so it triggered
assertion failures from within getLMULCost().

I am not sure what is the best way to handle this, or if there are more
such assertions within the codebase. But it feels reasonable to check
for V extension before assuming LMUL exists.
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2025

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

Author: Chenguang Wang (wecing)

Changes

We have a private extension which also uses the vector type in the frontend. Our platform does not have the V extension, so it triggered assertion failures from within getLMULCost().

I am not sure what is the best way to handle this, or if there are more such assertions within the codebase. But it feels reasonable to check for V extension before assuming LMUL exists.


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

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp (+3-2)
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 7bc0b5b394828..ababe42604ba5 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -2140,8 +2140,9 @@ InstructionCost RISCVTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
   // Assume memory ops cost scale with the number of vector registers
   // possible accessed by the instruction.  Note that BasicTTI already
   // handles the LT.first term for us.
-  if (LT.second.isVector() && CostKind != TTI::TCK_CodeSize)
-    BaseCost *= TLI->getLMULCost(LT.second);
+  if (TLI->getSubtarget().hasVInstructions())
+    if (LT.second.isVector() && CostKind != TTI::TCK_CodeSize)
+      BaseCost *= TLI->getLMULCost(LT.second);
   return Cost + BaseCost;
 }
 

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

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

LGTM

@wecing wecing merged commit 6d516c6 into llvm:main Nov 7, 2025
10 checks passed
vinay-deshmukh pushed a commit to vinay-deshmukh/llvm-project that referenced this pull request Nov 8, 2025
…166994)

We have a private extension which also uses the vector type in the
frontend. Our platform does not have the V extension, so it triggered
assertion failures from within getLMULCost().

It feels reasonable to check for V extension before assuming LMUL
exists.
@wecing wecing deleted the dev branch November 10, 2025 21:11
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.

3 participants