[llvm-branch-commits] [clang] [Clang][RISCV] Allow riscv_rvv_vector_bits typedefs shorter than VLEN*LMUL (PR #237846)

Kito Cheng via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 4 19:55:48 PST 2026


https://github.com/kito-cheng updated https://github.com/llvm/llvm-project/pull/237846

>From 9f1b8bc603b48f5a72ba88c0efa8ac4b38dc76a5 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at sifive.com>
Date: Tue, 13 Oct 2026 12:38:30 +0800
Subject: [PATCH 1/3] [Clang][RISCV] Allow riscv_rvv_vector_bits typedefs
 shorter than VLEN*LMUL

riscv_rvv_vector_bits(N) on a data type now accepts any N up to
VLEN * LMUL that gives a power-of-2 number of elements. Without
-mrvv-vector-bits=, VLEN is the minimum VLEN from -march.

A shorter typedef keeps the LMUL of its sizeless type and uses only the
low lanes. It converts implicitly to and from that sizeless type only.

Mask types are unchanged, that would be follow up PR for easier reivew.

Assisted-by: Claude
---
 clang/docs/ReleaseNotes.md                    |   6 +
 clang/include/clang/Basic/AttrDocs.td         |  23 ++-
 .../clang/Basic/DiagnosticSemaKinds.td        |   9 +
 clang/lib/AST/ASTContext.cpp                  |  30 ++-
 clang/lib/Sema/SemaType.cpp                   |  50 +++--
 .../CodeGen/RISCV/attr-rvv-vector-bits-lmul.c | 180 ++++++++++++++++++
 .../RISCV/attr-rvv-vector-bits-no-flag.c      |  40 ++++
 .../RISCV/attr-rvv-vector-bits-relaxed-call.c |  50 +++++
 .../attr-rvv-vector-bits-relaxed-convert.c    |  94 +++++++++
 .../riscv-mangle-rvv-fixed-vectors-lmul.cpp   |  39 ++++
 clang/test/Driver/riscv-rvv-vector-bits.c     |  15 +-
 .../Sema/attr-riscv-rvv-vector-bits-lmul.c    | 125 ++++++++++++
 .../Sema/attr-riscv-rvv-vector-bits-no-flag.c |  80 ++++++++
 .../Sema/attr-riscv-rvv-vector-bits-relaxed.c |  67 +++++++
 14 files changed, 778 insertions(+), 30 deletions(-)
 create mode 100644 clang/test/CodeGen/RISCV/attr-rvv-vector-bits-lmul.c
 create mode 100644 clang/test/CodeGen/RISCV/attr-rvv-vector-bits-no-flag.c
 create mode 100644 clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-call.c
 create mode 100644 clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-convert.c
 create mode 100644 clang/test/CodeGenCXX/riscv-mangle-rvv-fixed-vectors-lmul.cpp
 create mode 100644 clang/test/Sema/attr-riscv-rvv-vector-bits-lmul.c
 create mode 100644 clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
 create mode 100644 clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index a367196a601bc7..ed34bed7df8604 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -1327,6 +1327,12 @@ documentation](CIR/index.md) for more information regarding ClangIR's status and
   `-mcpu` is present, the ISA will be selected from the host CPU and the tune
   CPU will be selected from `-mcpu`.
 
+- `riscv_rvv_vector_bits(N)` now accepts any `N` up to `VLEN*LMUL` bits for
+  data types. For them it no longer requires `-mrvv-vector-bits`; without it,
+  `VLEN` is the minimum required by `-march`. A shorter typedef keeps the LMUL
+  of the type it was written against, and converts implicitly to and from that
+  sizeless type (truncating, or leaving the upper lanes undefined).
+
 #### CUDA/HIP Language Changes
 
 - HIP compilations now add the `include/libhipcxx` directory from the selected
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 687e022c7bd61f..89b8b86f3b9ed9 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3347,15 +3347,24 @@ can be used in globals, structs, unions, and arrays, all of which are
 unsupported for sizeless types.
 
 The attribute can be attached to a single RVV vector (such as `vint8m1_t`).
-The attribute will be rejected unless
-`N==(__riscv_v_fixed_vlen*LMUL)`, the implementation defined feature macro that
-is enabled under the `-mrvv-vector-bits` flag. `__riscv_v_fixed_vlen` can
-only be a power of 2 between 64 and 65536.
 
-For types where LMUL!=1, `__riscv_v_fixed_vlen` needs to be scaled by the LMUL
-of the type before passing to the attribute.
+For data types, `N` is a size in bits. It must be a positive multiple of the
+element size, `N` divided by the element size must be a power of 2, and `N`
+must not exceed `VLEN*LMUL`.
 
-For `vbool*_t` types, `__riscv_v_fixed_vlen` needs to be divided by the
+A data type with `N` smaller than `VLEN*LMUL` uses only the low lanes of the
+register group:
+
+- It keeps the LMUL of the type it was written against. For example,
+  `vint32m1_t` with `riscv_rvv_vector_bits(64)` occupies one vector register
+  and is a different type from `vint32mf2_t` with `riscv_rvv_vector_bits(64)`.
+- It converts implicitly to and from its own sizeless type only. Converting to
+  the sizeless type leaves the upper lanes undefined; converting back keeps the
+  first `N` bits. When such a value is passed to an RVV intrinsic, the
+  programmer must keep `vl` (and any `vrgather` index) within those lanes.
+
+For `vbool*_t` types, the attribute will be rejected unless
+`-mrvv-vector-bits` is given and `N` is `__riscv_v_fixed_vlen` divided by the
 number from the type name. For example, `vbool8_t` needs to use
 `__riscv_v_fixed_vlen` / 8. If the resulting value is not a multiple of 8,
 the type is not supported for that value of `__riscv_v_fixed_vlen`.
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 56cc9721781063..bbebbb37a3ce24 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3457,6 +3457,15 @@ def err_attribute_riscv_rvv_bits_unsupported : Error<
 def err_attribute_bad_rvv_vector_size : Error<
   "invalid RVV vector size '%0', expected size is '%1' based on LMUL of type "
   "and '-mrvv-vector-bits'">;
+def err_attribute_bad_rvv_vector_size_too_large : Error<
+  "invalid RVV vector size '%0', must not exceed '%1' based on LMUL of type "
+  "and the minimum VLEN">;
+def err_attribute_bad_rvv_vector_size_not_multiple_of_elem : Error<
+  "invalid RVV vector size '%0', must be a positive multiple of the element "
+  "size '%1'">;
+def err_attribute_bad_rvv_vector_size_not_pow2 : Error<
+  "invalid RVV vector size '%0', the resulting element count '%1' must be a "
+  "power of 2">;
 def err_attribute_invalid_rvv_type : Error<
   "%0 attribute applied to non-RVV type %1">;
 def err_attribute_requires_positive_integer : Error<
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6afc80a2b908bb..c821fb50d3b0f2 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -91,6 +91,7 @@
 #include "llvm/Support/SipHash.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/AArch64TargetParser.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include <algorithm>
 #include <cassert>
@@ -10850,6 +10851,16 @@ static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty) {
   return VScale->first * MinElts * EltSize;
 }
 
+/// Return log2 of the LMUL of a sizeless RVV data type, as
+/// getRVVFixedLengthDataLMulLog2() does for a vector kind.
+static int getRVVBuiltinLMulLog2(ASTContext &Context, const BuiltinType *Ty) {
+  ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Ty);
+  uint64_t SizeAtVScale1 =
+      Info.EC.getKnownMinValue() * Context.getTypeSize(Info.ElementType);
+  return int(llvm::Log2_64(SizeAtVScale1)) -
+         int(llvm::Log2_32(llvm::RISCV::RVVBitsPerBlock));
+}
+
 bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
                                        QualType SecondType) {
   assert(
@@ -10885,11 +10896,20 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
                  getTypeSize(SecondType) == ((getRVVTypeSize(*this, BT)) * 2);
         }
         if (isRVVFixedLengthDataVectorKind(VT->getVectorKind()) ||
-            VT->getVectorKind() == VectorKind::Generic)
-          return FirstType->isRVVVLSBuiltinType() &&
-                 getTypeSize(SecondType) == getRVVTypeSize(*this, BT) &&
-                 hasSameType(VT->getElementType(),
-                             getBuiltinVectorTypeInfo(BT).ElementType);
+            VT->getVectorKind() == VectorKind::Generic) {
+          bool IsRVVFixed = isRVVFixedLengthDataVectorKind(VT->getVectorKind());
+          BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT);
+          // A riscv_rvv_vector_bits typedef may be shorter than the sizeless
+          // type, but must have the same LMUL.
+          bool SizeOk =
+              IsRVVFixed ? getTypeSize(SecondType) <= getRVVTypeSize(*this, BT)
+                         : getTypeSize(SecondType) == getRVVTypeSize(*this, BT);
+          bool LMulOk = !IsRVVFixed || Info.ElementType == BoolTy ||
+                        getRVVFixedLengthDataLMulLog2(VT->getVectorKind()) ==
+                            getRVVBuiltinLMulLog2(*this, BT);
+          return FirstType->isRVVVLSBuiltinType() && SizeOk && LMulOk &&
+                 hasSameType(VT->getElementType(), Info.ElementType);
+        }
       }
     }
     return false;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 9c299b9e55da8d..f6137dd75f86fa 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8843,15 +8843,6 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
     return;
   }
 
-  auto VScale = S.Context.getTargetInfo().getVScaleRange(
-      S.getLangOpts(), TargetInfo::ArmStreamingKind::NotStreaming);
-  if (!VScale || !VScale->first || VScale->first != VScale->second) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
-        << Attr;
-    Attr.setInvalid();
-    return;
-  }
-
   // The vector size must be an integer constant expression.
   llvm::APSInt RVVVectorSizeInBits(32);
   if (!verifyValidIntegerConstantExpr(S, Attr, RVVVectorSizeInBits))
@@ -8870,13 +8861,25 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
   ASTContext::BuiltinVectorTypeInfo Info =
       S.Context.getBuiltinVectorTypeInfo(CurType->castAs<BuiltinType>());
   unsigned MinElts = Info.EC.getKnownMinValue();
+  bool IsMask = Info.ElementType == S.Context.BoolTy;
+
+  // A data type needs only the minimum VLEN; a mask type needs a fixed VLEN.
+  auto VScale = S.Context.getTargetInfo().getVScaleRange(
+      S.getLangOpts(), TargetInfo::ArmStreamingKind::NotStreaming);
+  if (!VScale || !VScale->first ||
+      (IsMask && VScale->first != VScale->second)) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
+        << Attr;
+    Attr.setInvalid();
+    return;
+  }
 
   VectorKind VecKind = VectorKind::RVVFixedLengthMask;
   unsigned ExpectedSize = VScale->first * MinElts;
   QualType EltType = CurType->getRVVEltType(S.Context);
   unsigned EltSize = S.Context.getTypeSize(EltType);
   unsigned NumElts;
-  if (Info.ElementType == S.Context.BoolTy) {
+  if (IsMask) {
     NumElts = VecSize / S.Context.getCharWidth();
     if (!NumElts) {
       NumElts = 1;
@@ -8905,14 +8908,37 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
         int(llvm::Log2_32(llvm::RISCV::RVVBitsPerBlock)));
   }
 
-  // The attribute vector size must match -mrvv-vector-bits.
-  if (VecSize != ExpectedSize) {
+  // The size of a mask type must match -mrvv-vector-bits.
+  if (IsMask && VecSize != ExpectedSize) {
     S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size)
         << VecSize << ExpectedSize;
     Attr.setInvalid();
     return;
   }
 
+  // A data type may be shorter than VLEN * LMUL, with a power-of-2 number of
+  // elements.
+  if (VecSize > ExpectedSize) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size_too_large)
+        << VecSize << ExpectedSize;
+    Attr.setInvalid();
+    return;
+  }
+  if (!IsMask && (VecSize == 0 || (VecSize % EltSize) != 0)) {
+    S.Diag(Attr.getLoc(),
+           diag::err_attribute_bad_rvv_vector_size_not_multiple_of_elem)
+        << VecSize << EltSize;
+    Attr.setInvalid();
+    return;
+  }
+  unsigned NumLanes = IsMask ? VecSize : NumElts;
+  if (!llvm::isPowerOf2_32(NumLanes)) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size_not_pow2)
+        << VecSize << NumLanes;
+    Attr.setInvalid();
+    return;
+  }
+
   CurType = S.Context.getVectorType(EltType, NumElts, VecKind);
 }
 
diff --git a/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-lmul.c b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-lmul.c
new file mode 100644
index 00000000000000..d851acc974a466
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-lmul.c
@@ -0,0 +1,180 @@
+// Verify that a riscv_rvv_vector_bits typedef keeps the LMUL of the sizeless
+// RVV type it was written against, rather than having it re-derived from VLEN
+// and the declared lane count.
+//
+// A typedef may declare fewer lanes than
+// VLEN * LMUL, so NumElements / vscale under-estimates the LMUL. Two typedefs
+// with the same element type and lane count but different LMULs must map to
+// different scalable vector types.
+//
+// VLEN=128 (vscale=2): vint32mf2_t holds 2 i32 lanes at full size,
+// vint32m1_t 4, vint32m2_t 8, vint32m4_t 16.
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -mvscale-min=2 -mvscale-max=2 \
+// RUN:   -O1 -emit-llvm -o - %s | FileCheck %s
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+// All of these hold 2 i32 lanes; only the LMUL differs.
+typedef vint32mf2_t mf2_64 __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t  m1_64  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m2_t  m2_64  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m4_t  m4_64  __attribute__((riscv_rvv_vector_bits(64)));
+
+// A single lane out of an LMUL=1 group.
+typedef vint32m1_t m1_32 __attribute__((riscv_rvv_vector_bits(32)));
+
+// Other element sizes.
+typedef vint8m1_t    i8m1_32   __attribute__((riscv_rvv_vector_bits(32)));
+typedef vint8mf4_t   i8mf4_16  __attribute__((riscv_rvv_vector_bits(16)));
+typedef vfloat32m1_t f32m1_64  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vfloat64m1_t f64m1_64  __attribute__((riscv_rvv_vector_bits(64)));
+
+//===----------------------------------------------------------------------===//
+// Same lane count, different LMUL => different ABI types.
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: define dso_local noundef <vscale x 1 x i32> @id_mf2_64(
+// CHECK-SAME:    <vscale x 1 x i32> {{.*}}%x.coerce)
+mf2_64 id_mf2_64(mf2_64 x) { return x; }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @id_m1_64(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+m1_64 id_m1_64(m1_64 x) { return x; }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 4 x i32> @id_m2_64(
+// CHECK-SAME:    <vscale x 4 x i32> {{.*}}%x.coerce)
+m2_64 id_m2_64(m2_64 x) { return x; }
+
+// Two lanes of an LMUL=4 type still occupy the whole LMUL=4 group.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 8 x i32> @id_m4_64(
+// CHECK-SAME:    <vscale x 8 x i32> {{.*}}%x.coerce)
+m4_64 id_m4_64(m4_64 x) { return x; }
+
+// One lane still occupies a whole LMUL=1 group.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @id_m1_32(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+m1_32 id_m1_32(m1_32 x) { return x; }
+
+//===----------------------------------------------------------------------===//
+// Other element sizes.
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 8 x i8> @id_i8m1_32(
+// CHECK-SAME:    <vscale x 8 x i8> {{.*}}%x.coerce)
+i8m1_32 id_i8m1_32(i8m1_32 x) { return x; }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i8> @id_i8mf4_16(
+// CHECK-SAME:    <vscale x 2 x i8> {{.*}}%x.coerce)
+i8mf4_16 id_i8mf4_16(i8mf4_16 x) { return x; }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x float> @id_f32m1_64(
+// CHECK-SAME:    <vscale x 2 x float> {{.*}}%x.coerce)
+f32m1_64 id_f32m1_64(f32m1_64 x) { return x; }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 1 x double> @id_f64m1_64(
+// CHECK-SAME:    <vscale x 1 x double> {{.*}}%x.coerce)
+f64m1_64 id_f64m1_64(f64m1_64 x) { return x; }
+
+//===----------------------------------------------------------------------===//
+// Calling RVV intrinsics with these typedefs. Because the ABI type already
+// matches the LMUL the intrinsic expects, the argument flows straight into the
+// intrinsic with no llvm.vector.insert / llvm.vector.extract in between.
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @add_m1(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%a.coerce, <vscale x 2 x i32> {{.*}}%b.coerce)
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 2 x i32> @llvm.riscv.vadd.nxv2i32.nxv2i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> %a.coerce, <vscale x 2 x i32> %b.coerce, i64 2)
+// CHECK-NEXT:    ret <vscale x 2 x i32> [[R]]
+m1_64 add_m1(m1_64 a, m1_64 b) { return __riscv_vadd_vv_i32m1(a, b, 2); }
+
+// Same lane count as add_m1, but the mf2 typedef selects the mf2 intrinsic.
+// CHECK-LABEL: define dso_local <vscale x 1 x i32> @add_mf2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 1 x i32> @llvm.riscv.vadd.nxv1i32.nxv1i32.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> %a.coerce, <vscale x 1 x i32> %b.coerce, i64 2)
+// CHECK-NEXT:    ret <vscale x 1 x i32> [[R]]
+mf2_64 add_mf2(mf2_64 a, mf2_64 b) { return __riscv_vadd_vv_i32mf2(a, b, 2); }
+
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 4 x i32> @add_m2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32.i64(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a.coerce, <vscale x 4 x i32> %b.coerce, i64 2)
+// CHECK-NEXT:    ret <vscale x 4 x i32> [[R]]
+m2_64 add_m2(m2_64 a, m2_64 b) { return __riscv_vadd_vv_i32m2(a, b, 2); }
+
+// Fractional LMUL with a narrow element type.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i8> @add_i8mf4(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 2 x i8> @llvm.riscv.vadd.nxv2i8.nxv2i8.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> %a.coerce, <vscale x 2 x i8> %b.coerce, i64 2)
+// CHECK-NEXT:    ret <vscale x 2 x i8> [[R]]
+i8mf4_16 add_i8mf4(i8mf4_16 a, i8mf4_16 b) {
+  return __riscv_vadd_vv_i8mf4(a, b, 2);
+}
+
+// Floating point.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x float> @fadd_m1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 2 x float> @llvm.riscv.vfadd.nxv2f32.nxv2f32.i64(<vscale x 2 x float> poison, <vscale x 2 x float> %a.coerce, <vscale x 2 x float> %b.coerce, i64 7, i64 2)
+// CHECK-NEXT:    ret <vscale x 2 x float> [[R]]
+f32m1_64 fadd_m1(f32m1_64 a, f32m1_64 b) {
+  return __riscv_vfadd_vv_f32m1(a, b, 2);
+}
+
+// Load returning into the shorter typedef.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @load_m1(
+// CHECK:         [[R:%.*]] = {{.*}}call <vscale x 2 x i32> @llvm.riscv.vle.nxv2i32.p0.i64(<vscale x 2 x i32> poison, ptr %p, i64 2)
+// CHECK-NEXT:    ret <vscale x 2 x i32> [[R]]
+m1_64 load_m1(const int *p) { return __riscv_vle32_v_i32m1(p, 2); }
+
+// Store taking the shorter typedef.
+// CHECK-LABEL: define dso_local void @store_m1(
+// CHECK:         call void @llvm.riscv.vse.nxv2i32.p0.i64(<vscale x 2 x i32> %v.coerce, ptr %p, i64 2)
+void store_m1(int *p, m1_64 v) { __riscv_vse32_v_i32m1(p, v, 2); }
+
+// Mask-producing and masked intrinsics: the mask LMUL follows the data LMUL.
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @masked_add_m1(
+// CHECK:         [[M:%.*]] = {{.*}}call <vscale x 2 x i1> @llvm.riscv.vmseq.nxv2i32.nxv2i32.i64(<vscale x 2 x i32> %a.coerce, <vscale x 2 x i32> %b.coerce, i64 2)
+// CHECK-NEXT:    [[R:%.*]] = {{.*}}call <vscale x 2 x i32> @llvm.riscv.vadd.mask.nxv2i32.nxv2i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> %a.coerce, <vscale x 2 x i32> %b.coerce, <vscale x 2 x i1> [[M]], i64 2, i64 3)
+// CHECK-NEXT:    ret <vscale x 2 x i32> [[R]]
+m1_64 masked_add_m1(m1_64 a, m1_64 b) {
+  vbool32_t m = __riscv_vmseq_vv_i32m1_b32(a, b, 2);
+  return __riscv_vadd_vv_i32m1_m(m, a, b, 2);
+}
+
+//===----------------------------------------------------------------------===//
+// Structs. The number of vector registers a field needs follows its LMUL, not
+// the number of lanes it declares.
+//===----------------------------------------------------------------------===//
+
+struct s1_m1 { m1_64 a; };
+// CHECK-LABEL: define dso_local void @st1_m1(
+// CHECK-SAME:    <vscale x 2 x i32>
+void st1_m1(struct s1_m1 s) {}
+
+struct s2_m1 { m1_64 a, b; };
+// CHECK-LABEL: define dso_local void @st2_m1(
+// CHECK-SAME:    target("riscv.vector.tuple", <vscale x 8 x i8>, 2)
+void st2_m1(struct s2_m1 s) {}
+
+struct s2_mf2 { mf2_64 a, b; };
+// CHECK-LABEL: define dso_local void @st2_mf2(
+// CHECK-SAME:    target("riscv.vector.tuple", <vscale x 4 x i8>, 2)
+void st2_mf2(struct s2_mf2 s) {}
+
+// 2 * LMUL4 = 8 registers, right at the limit.
+struct s2_m4 { m4_64 a, b; };
+// CHECK-LABEL: define dso_local void @st2_m4(
+// CHECK-SAME:    target("riscv.vector.tuple", <vscale x 32 x i8>, 2)
+void st2_m4(struct s2_m4 s) {}
+
+// 3 * LMUL4 = 12 registers, over the limit, so the struct is passed
+// indirectly. Deriving the LMUL from the lane count would have made this look
+// like 3 * LMUL(1/2) and wrongly passed it in registers.
+struct s3_m4 { m4_64 a, b, c; };
+// CHECK-LABEL: define dso_local void @st3_m4(
+// CHECK-SAME:    ptr
+void st3_m4(struct s3_m4 s) {}
diff --git a/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-no-flag.c b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-no-flag.c
new file mode 100644
index 00000000000000..eab187b70b2214
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-no-flag.c
@@ -0,0 +1,40 @@
+// Verify that riscv_rvv_vector_bits typedefs work without -mrvv-vector-bits=,
+// using only the ISA's Zvl*b extension as the lower bound. The fixed<->scalable
+// conversion IR landmarks must be present.
+
+// zvl128b, no -mrvv-vector-bits=:
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl128b \
+// RUN:   -O1 -emit-llvm -o - %s | FileCheck %s
+
+// The fixed<->scalable conversions fold away at -O1 now that both sides use
+// the same LMUL, so check the landmarks on unoptimized IR.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl128b \
+// RUN:   -O1 -disable-llvm-passes -emit-llvm -o - %s \
+// RUN:   | FileCheck %s --check-prefix=RAW
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+typedef vint32m1_t m1_64 __attribute__((riscv_rvv_vector_bits(64)));
+
+// Fixed -> scalable conversion uses insert into poison. m1_64 keeps LMUL 1, so
+// the ABI type already matches vint32m1_t and the conversion folds away.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @widen
+// RAW: call <vscale x 2 x i32> @llvm.vector.insert.nxv2i32.v2i32(<vscale x 2 x i32> poison
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @widen
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret <vscale x 2 x i32> %x.coerce
+vint32m1_t widen(m1_64 x) { return x; }
+
+// Scalable -> fixed conversion uses extract.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @narrow
+// RAW: call <2 x i32> @llvm.vector.extract.v2i32.nxv2i32(
+// CHECK-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @narrow
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret <vscale x 2 x i32> %x
+m1_64 narrow(vint32m1_t x) { return x; }
diff --git a/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-call.c b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-call.c
new file mode 100644
index 00000000000000..26a6c4988d5a3f
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-call.c
@@ -0,0 +1,50 @@
+// Verify CodeGen coercion for shorter riscv_rvv_vector_bits typedefs.
+//
+// A shorter typedef keeps the LMUL of the sizeless type it was written
+// against, so it is passed in the same register group as the full-size
+// typedef; only the lanes it declares hold defined data.
+//
+// VLEN=128 (vscale=2): vint32m1_t has 4 i32 lanes at full size.
+//   - bits(128) -> <4 x i32> -> <vscale x 2 x i32> (m1, all 4 lanes used)
+//   - bits(64)  -> <2 x i32> -> <vscale x 2 x i32> (m1, upper 2 lanes garbage)
+//   - bits(32)  -> <1 x i32> -> <vscale x 2 x i32> (m1, upper 3 lanes garbage)
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -mvscale-min=2 -mvscale-max=2 \
+// RUN:   -O1 -emit-llvm -o - %s | FileCheck %s
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+typedef vint32m1_t fixed_i32x4 __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t fixed_i32x2 __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t fixed_i32x1 __attribute__((riscv_rvv_vector_bits(32)));
+typedef vint8m1_t  fixed_i8x4  __attribute__((riscv_rvv_vector_bits(32)));
+
+// Full-size case still works the same as the strict path.
+// CHECK-LABEL: define dso_local{{.*}} <vscale x 2 x i32> @id_i32x4(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+// CHECK:         ret <vscale x 2 x i32> %x.coerce
+fixed_i32x4 id_i32x4(fixed_i32x4 x) { return x; }
+
+// Half the lanes, same LMUL: still <vscale x 2 x i32>, not <vscale x 1 x i32>.
+// CHECK-LABEL: define dso_local{{.*}} <vscale x 2 x i32> @id_i32x2(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+fixed_i32x2 id_i32x2(fixed_i32x2 x) { return x; }
+
+// A single lane still occupies a whole LMUL=1 register group.
+// CHECK-LABEL: define dso_local{{.*}} <vscale x 2 x i32> @id_i32x1(
+// CHECK-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+fixed_i32x1 id_i32x1(fixed_i32x1 x) { return x; }
+
+// 4 i8 lanes = 32 bits out of a 128-bit LMUL=1 group, which holds 8 i8 lanes
+// at vscale=1.
+// CHECK-LABEL: define dso_local{{.*}} <vscale x 8 x i8> @id_i8x4(
+// CHECK-SAME:    <vscale x 8 x i8> {{.*}}%x.coerce)
+fixed_i8x4 id_i8x4(fixed_i8x4 x) { return x; }
+
+// Note: implicit conversion between shorter fixed types and the sizeless
+// VLA type (e.g. calling sizeless_callee(fixed_i32x2)) is handled by
+// Phase 3 and is intentionally not exercised here.
diff --git a/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-convert.c b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-convert.c
new file mode 100644
index 00000000000000..7d0c278bfc0513
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/attr-rvv-vector-bits-relaxed-convert.c
@@ -0,0 +1,94 @@
+// Verify implicit conversion semantics between a shorter
+// riscv_rvv_vector_bits typedef and the underlying sizeless RVV type.
+//
+// VLEN=128 (vscale=2): vint32m1_t = <vscale x 2 x i32> (4 lanes total).
+// A shorter typedef of vint32m1_t keeps LMUL 1, so it ABI-coerces to
+// <vscale x 2 x i32> as well and only differs in how many lanes carry
+// defined data:
+//   fixed_i32x2 (bits(64)) declares 2 of the 4 i32 lanes.
+//   fixed_i32x1 (bits(32)) declares 1 of the 4 i32 lanes.
+//
+// RAW checks the conversions Clang emits: llvm.vector.extract to truncate
+// down to the declared lanes and llvm.vector.insert into poison to widen back
+// with garbage. OPT checks that, because both sides now agree on LMUL, the
+// round trips fold away entirely instead of leaving a change of register
+// group behind.
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -mvscale-min=2 -mvscale-max=2 \
+// RUN:   -O1 -disable-llvm-passes -emit-llvm -o - %s \
+// RUN:   | FileCheck %s --check-prefix=RAW
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -mvscale-min=2 -mvscale-max=2 \
+// RUN:   -O1 -emit-llvm -o - %s | FileCheck %s --check-prefix=OPT
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+typedef vint32m1_t fixed_i32x4 __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t fixed_i32x2 __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t fixed_i32x1 __attribute__((riscv_rvv_vector_bits(32)));
+
+vint32m1_t sizeless_callee(vint32m1_t x);
+
+// fixed_i32x2 -> vint32m1_t: garbage-fill the lanes the typedef does not
+// declare.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @widen(
+// RAW-SAME:    <vscale x 2 x i32> {{.*}}%x.coerce)
+// RAW:         [[T0:%.*]] = call <2 x i32> @llvm.vector.extract.v2i32.nxv2i32(<vscale x 2 x i32> %x.coerce, i64 0)
+// RAW:         call <vscale x 2 x i32> @llvm.vector.insert.nxv2i32.v2i32(<vscale x 2 x i32> poison, <2 x i32> {{.*}}, i64 0)
+//
+// OPT-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @widen(
+// OPT-NEXT:  entry:
+// OPT-NEXT:    ret <vscale x 2 x i32> %x.coerce
+vint32m1_t widen(fixed_i32x2 x) { return x; }
+
+// vint32m1_t -> fixed_i32x2: truncate to the first 2 lanes.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @narrow(
+// RAW:         [[T0:%.*]] = call <2 x i32> @llvm.vector.extract.v2i32.nxv2i32(<vscale x 2 x i32> {{.*}}, i64 0)
+//
+// OPT-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @narrow(
+// OPT-NEXT:  entry:
+// OPT-NEXT:    ret <vscale x 2 x i32> %x
+fixed_i32x2 narrow(vint32m1_t x) { return x; }
+
+// vint32m1_t -> fixed_i32x1: truncate to the first lane, still returned in a
+// whole LMUL=1 register.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @narrow_to_1(
+// RAW:         call <1 x i32> @llvm.vector.extract.v1i32.nxv2i32(<vscale x 2 x i32> {{.*}}, i64 0)
+// RAW:         call <vscale x 2 x i32> @llvm.vector.insert.nxv2i32.v1i32(<vscale x 2 x i32> poison, <1 x i32> {{.*}}, i64 0)
+fixed_i32x1 narrow_to_1(vint32m1_t x) { return x; }
+
+// fixed_i32x1 -> vint32m1_t: 1-lane garbage fill.
+// RAW-LABEL: define dso_local <vscale x 2 x i32> @widen_from_1(
+// RAW:         call <1 x i32> @llvm.vector.extract.v1i32.nxv2i32(<vscale x 2 x i32> %x.coerce, i64 0)
+// RAW:         call <vscale x 2 x i32> @llvm.vector.insert.nxv2i32.v1i32(<vscale x 2 x i32> poison, <1 x i32> {{.*}}, i64 0)
+vint32m1_t widen_from_1(fixed_i32x1 x) { return x; }
+
+// Round-trip is a no-op after optimization: coerce in and out at the same
+// scalable type.
+// OPT-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @round_trip(
+// OPT-NEXT:  entry:
+// OPT-NEXT:    ret <vscale x 2 x i32> %x.coerce
+fixed_i32x2 round_trip(fixed_i32x2 x) {
+  vint32m1_t s = x;
+  return s;
+}
+
+// Cross-call: passing a shorter fixed type to a sizeless callee needs no
+// register-group change at all, since both are LMUL 1.
+// OPT-LABEL: define dso_local {{.*}}<vscale x 2 x i32> @pass_short(
+// OPT-NEXT:  entry:
+// OPT-NEXT:    [[C:%.*]] = {{.*}}call <vscale x 2 x i32> @sizeless_callee(<vscale x 2 x i32> %x.coerce)
+// OPT-NEXT:    ret <vscale x 2 x i32> [[C]]
+vint32m1_t pass_short(fixed_i32x2 x) { return sizeless_callee(x); }
+
+// Full-size case: unchanged from the strict path.
+// OPT-LABEL: define dso_local noundef <vscale x 2 x i32> @widen_full(
+// OPT-NEXT:  entry:
+// OPT-NEXT:    ret <vscale x 2 x i32> %x.coerce
+vint32m1_t widen_full(fixed_i32x4 x) { return x; }
diff --git a/clang/test/CodeGenCXX/riscv-mangle-rvv-fixed-vectors-lmul.cpp b/clang/test/CodeGenCXX/riscv-mangle-rvv-fixed-vectors-lmul.cpp
new file mode 100644
index 00000000000000..47890dd225ae78
--- /dev/null
+++ b/clang/test/CodeGenCXX/riscv-mangle-rvv-fixed-vectors-lmul.cpp
@@ -0,0 +1,39 @@
+// Verify that the LMUL suffix in the mangled name of a riscv_rvv_vector_bits
+// typedef comes from the type the typedef was written against, not from VLEN.
+// Two typedefs holding the same number of lanes of the same element type but
+// derived from different LMULs must mangle
+// differently, and - because the suffix no longer depends on VLEN - the same
+// source mangles identically at zvl128b and zvl256b.
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu %s -emit-llvm -o - \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl128b \
+// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu %s -emit-llvm -o - \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl256b \
+// RUN:   | FileCheck %s
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+// All three hold 2 i32 lanes but come from different LMULs.
+typedef vint32mf2_t mf2_64 __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t  m1_64  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m2_t  m2_64  __attribute__((riscv_rvv_vector_bits(64)));
+
+// Overloading on the three types only compiles if they are distinct types.
+void f(mf2_64);
+void f(m1_64);
+void f(m2_64);
+
+void use(mf2_64 a, m1_64 b, m2_64 c) {
+  f(a);
+  f(b);
+  f(c);
+}
+
+// CHECK: declare {{.*}}@_Z1f9__RVV_VLSIu16__rvv_int32mf2_tLj64EE
+// CHECK: declare {{.*}}@_Z1f9__RVV_VLSIu15__rvv_int32m1_tLj64EE
+// CHECK: declare {{.*}}@_Z1f9__RVV_VLSIu15__rvv_int32m2_tLj64EE
diff --git a/clang/test/Driver/riscv-rvv-vector-bits.c b/clang/test/Driver/riscv-rvv-vector-bits.c
index 24af5f0c73c6ef..33fe0798716171 100644
--- a/clang/test/Driver/riscv-rvv-vector-bits.c
+++ b/clang/test/Driver/riscv-rvv-vector-bits.c
@@ -44,23 +44,26 @@
 
 // CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option '-mrvv-vector-bits='
 
-// Error if using attribute without -mrvv-vector-bits=<bits> or if using -mrvv-vector-bits=<bits>+ syntax
+// Error if using attribute without -mrvv-vector-bits=<bits> or with
+// -mrvv-vector-bits=scalable when the ISA string does not guarantee a VLEN of
+// at least 64. Otherwise the minimum VLEN from the ISA string is enough.
 // -----------------------------------------------------------------------------
 // RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \
-// RUN:  -march=rv64gc_zve64x 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
+// RUN:  -march=rv64gc_zve32x 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
 // RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \
-// RUN:  -march=rv64gc_zve64x -mrvv-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
+// RUN:  -march=rv64gc_zve32x -mrvv-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
 
 typedef __rvv_int32m1_t vint32m1_t;
-typedef vint32m1_t noflag __attribute__((riscv_rvv_vector_bits(256)));
+typedef __rvv_bool32_t vbool32_t;
+typedef vbool32_t noflag __attribute__((riscv_rvv_vector_bits(4)));
 
 // CHECK-NO-FLAG-ERROR: error: 'riscv_rvv_vector_bits' is only supported when '-mrvv-vector-bits=<bits>' is specified with a value of "zvl" or a power 2 in the range [64,65536]
 
-// Error if attribute vector size != -mrvv-vector-bits
+// Error if attribute vector size > -mrvv-vector-bits
 // -----------------------------------------------------------------------------
 // RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \
 // RUN:  -march=rv64gc_zve64x -mrvv-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-BAD-VECTOR-SIZE-ERROR %s
 
 typedef vint32_t bad_vector_size __attribute__((riscv_rvv_vector_bits(256)));
 
-// CHECK-BAD-VECTOR-SIZE-ERROR: error: invalid RVV vector size '256', expected size is '128' based on LMUL of type and '-mrvv-vector-bits'
+// CHECK-BAD-VECTOR-SIZE-ERROR: error: invalid RVV vector size '256', must not exceed '128' based on LMUL of type and the minimum VLEN
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-lmul.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-lmul.c
new file mode 100644
index 00000000000000..1516f0e3344aae
--- /dev/null
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-lmul.c
@@ -0,0 +1,125 @@
+// Verify that a riscv_rvv_vector_bits typedef keeps the LMUL of the sizeless
+// RVV type it was written against. Two typedefs can hold the same number of lanes of the same element type while
+// coming from different LMULs, and they must stay distinct types.
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -ffreestanding -fsyntax-only -verify=expected -mvscale-min=2 \
+// RUN:   -mvscale-max=2 %s
+
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -ffreestanding -fsyntax-only -verify=expected,nolax -mvscale-min=2 \
+// RUN:   -mvscale-max=2 \
+// RUN:   -flax-vector-conversions=none %s
+
+// REQUIRES: riscv-registered-target
+
+#include <riscv_vector.h>
+
+// VLEN=128: vint32m1_t holds 4 i32 lanes at full size, vint32mf2_t holds 2,
+// vint32m2_t holds 8. All three typedefs below hold 2 i32 lanes.
+typedef vint32m1_t  m1_64  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32mf2_t mf2_64 __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m2_t  m2_64  __attribute__((riscv_rvv_vector_bits(64)));
+
+//===----------------------------------------------------------------------===//
+// Same element type and lane count, different LMUL => distinct types.
+//
+// They are still the same size, so a lax vector conversion allows a direct
+// assignment between them as a reinterpret, exactly as it does for GNU
+// vectors. -flax-vector-conversions defaults to "all", so this is on unless
+// asked otherwise; turning it off shows that the types really are distinct.
+//===----------------------------------------------------------------------===//
+
+void distinct_types(void) {
+  m1_64 a;
+  mf2_64 b;
+  m2_64 c;
+
+  a = b; // nolax-error {{assigning to 'm1_64' (vector of 2 'int' values) from incompatible type 'mf2_64'}}
+  b = a; // nolax-error {{assigning to 'mf2_64' (vector of 2 'int' values) from incompatible type 'm1_64'}}
+  a = c; // nolax-error {{assigning to 'm1_64' (vector of 2 'int' values) from incompatible type 'm2_64'}}
+}
+
+//===----------------------------------------------------------------------===//
+// Conversion to and from the sizeless type is only allowed for the matching
+// LMUL. This goes through areCompatibleRVVTypes, so it is rejected regardless
+// of the lax vector conversion setting.
+//===----------------------------------------------------------------------===//
+
+void to_sizeless(void) {
+  m1_64 a;
+
+  vint32m1_t ok = a;
+  (void)ok;
+
+  vint32mf2_t narrower = a; // expected-error {{initializing 'vint32mf2_t' (aka '__rvv_int32mf2_t') with an expression of incompatible type 'm1_64'}}
+  (void)narrower;
+
+  vint32m2_t wider = a; // expected-error {{initializing 'vint32m2_t' (aka '__rvv_int32m2_t') with an expression of incompatible type 'm1_64'}}
+  (void)wider;
+}
+
+void from_sizeless(vint32m1_t v1, vint32mf2_t vh, vint32m2_t v2) {
+  m1_64 ok = v1;
+  (void)ok;
+
+  m1_64 bad_narrower = vh; // expected-error {{with an expression of incompatible type 'vint32mf2_t' (aka '__rvv_int32mf2_t')}}
+  (void)bad_narrower;
+
+  m1_64 bad_wider = v2; // expected-error {{with an expression of incompatible type 'vint32m2_t' (aka '__rvv_int32m2_t')}}
+  (void)bad_wider;
+}
+
+//===----------------------------------------------------------------------===//
+// Calling RVV intrinsics: only the intrinsic of the matching LMUL accepts a
+// shorter typedef.
+//===----------------------------------------------------------------------===//
+
+void intrinsics_m1(m1_64 a, m1_64 b) {
+  // Matching LMUL: fine.
+  m1_64 sum = __riscv_vadd_vv_i32m1(a, b, 2);
+  (void)sum;
+
+  // Fewer lanes than the typedef's LMUL provides.
+  (void)__riscv_vadd_vv_i32mf2(a, b, 2); // expected-error {{passing 'm1_64' (vector of 2 'int' values) to parameter of incompatible type '__rvv_int32mf2_t'}} \
+                                         // expected-note {{passing argument to parameter here}}
+
+  // More lanes than the typedef's LMUL provides.
+  (void)__riscv_vadd_vv_i32m2(a, b, 2); // expected-error {{passing 'm1_64' (vector of 2 'int' values) to parameter of incompatible type '__rvv_int32m2_t'}} \
+                                        // expected-note {{passing argument to parameter here}}
+}
+
+void intrinsics_mf2(mf2_64 a, mf2_64 b) {
+  mf2_64 sum = __riscv_vadd_vv_i32mf2(a, b, 2);
+  (void)sum;
+
+  (void)__riscv_vadd_vv_i32m1(a, b, 2); // expected-error {{passing 'mf2_64' (vector of 2 'int' values) to parameter of incompatible type '__rvv_int32m1_t'}} \
+                                        // expected-note {{passing argument to parameter here}}
+}
+
+// Loads and stores of the matching LMUL are fine.
+void intrinsics_mem(const int *p, int *q) {
+  m1_64 v = __riscv_vle32_v_i32m1(p, 2);
+  __riscv_vse32_v_i32m1(q, v, 2);
+}
+
+//===----------------------------------------------------------------------===//
+// A full-size typedef behaves the same way: LMUL comes from the typedef, not
+// from the lane count.
+//===----------------------------------------------------------------------===//
+
+typedef vint32m1_t m1_128 __attribute__((riscv_rvv_vector_bits(128)));
+
+// The mf2 type cannot even hold 128 bits at this VLEN.
+typedef vint32mf2_t mf2_128 __attribute__((riscv_rvv_vector_bits(128))); // expected-error {{invalid RVV vector size '128', must not exceed '64' based on LMUL of type and the minimum VLEN}}
+
+void full_size(void) {
+  m1_128 a;
+  vint32m1_t ok = a;
+  (void)ok;
+
+  vint32m2_t bad = a; // expected-error {{initializing 'vint32m2_t' (aka '__rvv_int32m2_t') with an expression of incompatible type 'm1_128'}}
+  (void)bad;
+}
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
new file mode 100644
index 00000000000000..807a83f68eb25d
--- /dev/null
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
@@ -0,0 +1,80 @@
+// Tests for riscv_rvv_vector_bits when no fixed VLEN is supplied (i.e. no
+// -mrvv-vector-bits=). The bound for riscv_rvv_vector_bits(N) on
+// a data type then comes from the ISA's Zvl*b extension, scaled by LMUL.
+//
+// Bound: N <= MinElts * EltSize * zvl / RVVBitsPerBlock = zvl * LMUL (bits)
+//
+// vintXm1_t  -> bound = zvl
+// vintXm2_t  -> bound = zvl * 2
+// vintXmf2_t -> bound = zvl / 2
+//
+// Mask types still need -mrvv-vector-bits=.
+
+// zvl128b: ISA minimum VLEN = 128.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl128b \
+// RUN:   -ffreestanding -fsyntax-only -verify \
+// RUN:   %s
+
+// zvl256b: ISA minimum VLEN = 256.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl256b \
+// RUN:   -ffreestanding -fsyntax-only -verify \
+// RUN:   -DZVL256 %s
+
+typedef __rvv_int32m1_t  vint32m1_t;
+typedef __rvv_int32m2_t  vint32m2_t;
+typedef __rvv_int32mf2_t vint32mf2_t;
+typedef __rvv_bool32_t   vbool32_t;
+
+#if defined(ZVL256)
+
+// zvl256b: m1 bound is 256.
+typedef vint32m1_t  m1_eq  __attribute__((riscv_rvv_vector_bits(256)));
+typedef vint32m1_t  m1_lt  __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t  m1_too __attribute__((riscv_rvv_vector_bits(512)));
+// expected-error at -1 {{invalid RVV vector size '512', must not exceed '256' based on LMUL of type and the minimum VLEN}}
+
+// zvl256b: m2 bound is 512.
+typedef vint32m2_t  m2_eq  __attribute__((riscv_rvv_vector_bits(512)));
+typedef vint32m2_t  m2_lt  __attribute__((riscv_rvv_vector_bits(256)));
+typedef vint32m2_t  m2_too __attribute__((riscv_rvv_vector_bits(1024)));
+// expected-error at -1 {{invalid RVV vector size '1024', must not exceed '512' based on LMUL of type and the minimum VLEN}}
+
+// zvl256b: mf2 bound is 128.
+typedef vint32mf2_t mf2_eq  __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32mf2_t mf2_lt  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32mf2_t mf2_too __attribute__((riscv_rvv_vector_bits(256)));
+// expected-error at -1 {{invalid RVV vector size '256', must not exceed '128' based on LMUL of type and the minimum VLEN}}
+
+#else // zvl128b
+
+// zvl128b: m1 bound is 128.
+typedef vint32m1_t  m1_eq  __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t  m1_lt  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t  m1_min __attribute__((riscv_rvv_vector_bits(32)));
+typedef vint32m1_t  m1_too __attribute__((riscv_rvv_vector_bits(256)));
+// expected-error at -1 {{invalid RVV vector size '256', must not exceed '128' based on LMUL of type and the minimum VLEN}}
+
+// zvl128b: m2 bound is 256.
+typedef vint32m2_t  m2_eq  __attribute__((riscv_rvv_vector_bits(256)));
+typedef vint32m2_t  m2_lt  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m2_t  m2_too __attribute__((riscv_rvv_vector_bits(512)));
+// expected-error at -1 {{invalid RVV vector size '512', must not exceed '256' based on LMUL of type and the minimum VLEN}}
+
+// zvl128b: mf2 bound is 64.
+typedef vint32mf2_t mf2_eq  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32mf2_t mf2_lt  __attribute__((riscv_rvv_vector_bits(32)));
+typedef vint32mf2_t mf2_too __attribute__((riscv_rvv_vector_bits(128)));
+// expected-error at -1 {{invalid RVV vector size '128', must not exceed '64' based on LMUL of type and the minimum VLEN}}
+
+// Lane count must be a power of two.
+typedef vint32m1_t m1_npow2 __attribute__((riscv_rvv_vector_bits(96)));
+// expected-error at -1 {{invalid RVV vector size '96', the resulting element count '3' must be a power of 2}}
+
+typedef vbool32_t mask __attribute__((riscv_rvv_vector_bits(4)));
+// expected-error at -1 {{'riscv_rvv_vector_bits' is only supported when '-mrvv-vector-bits=<bits>' is specified with a value of "zvl" or a power 2 in the range [64,65536]}}
+
+#endif
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c
new file mode 100644
index 00000000000000..d1d9776bab8699
--- /dev/null
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c
@@ -0,0 +1,67 @@
+// VLEN=128: vint32m1_t has 4 elems at full size, vint8m1_t has 16 elems.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl128b \
+// RUN:   -ffreestanding -fsyntax-only -verify \
+// RUN:   %s
+
+// VLEN=512: vint32m1_t has 16 elems at full size.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl512b \
+// RUN:   -ffreestanding -fsyntax-only -verify \
+// RUN:   -DVLEN512 %s
+
+typedef __rvv_int32m1_t vint32m1_t;
+typedef __rvv_int8m1_t vint8m1_t;
+typedef __rvv_bool32_t vbool32_t;
+
+#if !defined(VLEN512) // VLEN=128
+
+// Equal-size case still works (compat).
+typedef vint32m1_t v_eq_i32 __attribute__((riscv_rvv_vector_bits(128)));
+
+// Shorter sizes (power of 2) are accepted.
+typedef vint32m1_t v_i32x2 __attribute__((riscv_rvv_vector_bits(64)));   // 2 elems
+typedef vint32m1_t v_i32x1 __attribute__((riscv_rvv_vector_bits(32)));   // 1 elem
+typedef vint8m1_t  v_i8x8  __attribute__((riscv_rvv_vector_bits(64)));   // 8 elems
+typedef vint8m1_t  v_i8x4  __attribute__((riscv_rvv_vector_bits(32)));   // 4 elems
+
+// Reject N > vlen*lmul.
+typedef vint32m1_t too_big __attribute__((riscv_rvv_vector_bits(256)));
+// expected-error at -1 {{invalid RVV vector size '256', must not exceed '128' based on LMUL of type and the minimum VLEN}}
+
+// Reject element count that is not a power of 2.
+typedef vint32m1_t three_elems __attribute__((riscv_rvv_vector_bits(96)));
+// expected-error at -1 {{invalid RVV vector size '96', the resulting element count '3' must be a power of 2}}
+
+// Reject sizes that aren't a multiple of the element size.
+typedef vint32m1_t odd_bits __attribute__((riscv_rvv_vector_bits(40)));
+// expected-error at -1 {{invalid RVV vector size '40', must be a positive multiple of the element size '32'}}
+
+// Reject zero.
+typedef vint32m1_t zero_bits __attribute__((riscv_rvv_vector_bits(0)));
+// expected-error at -1 {{invalid RVV vector size '0', must be a positive multiple of the element size '32'}}
+
+// Masks must still match exactly, counted in lanes: vbool32_t has 4 lanes.
+typedef vbool32_t mask_full __attribute__((riscv_rvv_vector_bits(4)));
+typedef vbool32_t mask_shorter __attribute__((riscv_rvv_vector_bits(2)));
+// expected-error at -1 {{invalid RVV vector size '2', expected size is '4' based on LMUL of type and '-mrvv-vector-bits'}}
+
+#else // VLEN=512
+
+typedef vint32m1_t v_full   __attribute__((riscv_rvv_vector_bits(512)));
+typedef vint32m1_t v_i32x8  __attribute__((riscv_rvv_vector_bits(256)));
+typedef vint32m1_t v_i32x4  __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t v_i32x2  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t v_i32x1  __attribute__((riscv_rvv_vector_bits(32)));
+
+// Still reject N > vlen*lmul.
+typedef vint32m1_t too_big __attribute__((riscv_rvv_vector_bits(1024)));
+// expected-error at -1 {{invalid RVV vector size '1024', must not exceed '512' based on LMUL of type and the minimum VLEN}}
+
+// Reject non-pow2 element count (5 * 32 = 160).
+typedef vint32m1_t five_elems __attribute__((riscv_rvv_vector_bits(160)));
+// expected-error at -1 {{invalid RVV vector size '160', the resulting element count '5' must be a power of 2}}
+
+#endif

>From c977e3f680bceb2680f2e4d95f9ceecd0db52e5e Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at sifive.com>
Date: Mon, 2 Nov 2026 19:32:44 +0800
Subject: [PATCH 2/3] fixup! [Clang][RISCV] Allow riscv_rvv_vector_bits
 typedefs shorter than VLEN*LMUL

---
 .../attr-riscv-rvv-vector-bits-relaxed-mask.c | 12 +++++++
 ...r-riscv-rvv-vector-bits-relaxed-zvl128b.c} | 36 +------------------
 ...tr-riscv-rvv-vector-bits-relaxed-zvl512b.c | 21 +++++++++++
 3 files changed, 34 insertions(+), 35 deletions(-)
 create mode 100644 clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-mask.c
 rename clang/test/Sema/{attr-riscv-rvv-vector-bits-relaxed.c => attr-riscv-rvv-vector-bits-relaxed-zvl128b.c} (51%)
 create mode 100644 clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl512b.c

diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-mask.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-mask.c
new file mode 100644
index 00000000000000..774caa8c2688e6
--- /dev/null
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-mask.c
@@ -0,0 +1,12 @@
+// Mask types still need a fixed VLEN.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -mvscale-min=2 -mvscale-max=2 \
+// RUN:   -ffreestanding -fsyntax-only -verify %s
+
+typedef __rvv_bool32_t vbool32_t;
+
+// Masks must still match exactly, counted in lanes: vbool32_t has 4 lanes.
+typedef vbool32_t mask_full __attribute__((riscv_rvv_vector_bits(4)));
+typedef vbool32_t mask_shorter __attribute__((riscv_rvv_vector_bits(2)));
+// expected-error at -1 {{invalid RVV vector size '2', expected size is '4' based on LMUL of type and '-mrvv-vector-bits'}}
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl128b.c
similarity index 51%
rename from clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c
rename to clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl128b.c
index d1d9776bab8699..7ca487401b5e95 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl128b.c
@@ -2,21 +2,10 @@
 // RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
 // RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
 // RUN:   -target-feature +zvl128b \
-// RUN:   -ffreestanding -fsyntax-only -verify \
-// RUN:   %s
-
-// VLEN=512: vint32m1_t has 16 elems at full size.
-// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
-// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
-// RUN:   -target-feature +zvl512b \
-// RUN:   -ffreestanding -fsyntax-only -verify \
-// RUN:   -DVLEN512 %s
+// RUN:   -ffreestanding -fsyntax-only -verify %s
 
 typedef __rvv_int32m1_t vint32m1_t;
 typedef __rvv_int8m1_t vint8m1_t;
-typedef __rvv_bool32_t vbool32_t;
-
-#if !defined(VLEN512) // VLEN=128
 
 // Equal-size case still works (compat).
 typedef vint32m1_t v_eq_i32 __attribute__((riscv_rvv_vector_bits(128)));
@@ -42,26 +31,3 @@ typedef vint32m1_t odd_bits __attribute__((riscv_rvv_vector_bits(40)));
 // Reject zero.
 typedef vint32m1_t zero_bits __attribute__((riscv_rvv_vector_bits(0)));
 // expected-error at -1 {{invalid RVV vector size '0', must be a positive multiple of the element size '32'}}
-
-// Masks must still match exactly, counted in lanes: vbool32_t has 4 lanes.
-typedef vbool32_t mask_full __attribute__((riscv_rvv_vector_bits(4)));
-typedef vbool32_t mask_shorter __attribute__((riscv_rvv_vector_bits(2)));
-// expected-error at -1 {{invalid RVV vector size '2', expected size is '4' based on LMUL of type and '-mrvv-vector-bits'}}
-
-#else // VLEN=512
-
-typedef vint32m1_t v_full   __attribute__((riscv_rvv_vector_bits(512)));
-typedef vint32m1_t v_i32x8  __attribute__((riscv_rvv_vector_bits(256)));
-typedef vint32m1_t v_i32x4  __attribute__((riscv_rvv_vector_bits(128)));
-typedef vint32m1_t v_i32x2  __attribute__((riscv_rvv_vector_bits(64)));
-typedef vint32m1_t v_i32x1  __attribute__((riscv_rvv_vector_bits(32)));
-
-// Still reject N > vlen*lmul.
-typedef vint32m1_t too_big __attribute__((riscv_rvv_vector_bits(1024)));
-// expected-error at -1 {{invalid RVV vector size '1024', must not exceed '512' based on LMUL of type and the minimum VLEN}}
-
-// Reject non-pow2 element count (5 * 32 = 160).
-typedef vint32m1_t five_elems __attribute__((riscv_rvv_vector_bits(160)));
-// expected-error at -1 {{invalid RVV vector size '160', the resulting element count '5' must be a power of 2}}
-
-#endif
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl512b.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl512b.c
new file mode 100644
index 00000000000000..7697a648830e9b
--- /dev/null
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-relaxed-zvl512b.c
@@ -0,0 +1,21 @@
+// VLEN=512: vint32m1_t has 16 elems at full size.
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu \
+// RUN:   -target-feature +f -target-feature +d -target-feature +zve64d \
+// RUN:   -target-feature +zvl512b \
+// RUN:   -ffreestanding -fsyntax-only -verify %s
+
+typedef __rvv_int32m1_t vint32m1_t;
+
+typedef vint32m1_t v_full   __attribute__((riscv_rvv_vector_bits(512)));
+typedef vint32m1_t v_i32x8  __attribute__((riscv_rvv_vector_bits(256)));
+typedef vint32m1_t v_i32x4  __attribute__((riscv_rvv_vector_bits(128)));
+typedef vint32m1_t v_i32x2  __attribute__((riscv_rvv_vector_bits(64)));
+typedef vint32m1_t v_i32x1  __attribute__((riscv_rvv_vector_bits(32)));
+
+// Still reject N > vlen*lmul.
+typedef vint32m1_t too_big __attribute__((riscv_rvv_vector_bits(1024)));
+// expected-error at -1 {{invalid RVV vector size '1024', must not exceed '512' based on LMUL of type and the minimum VLEN}}
+
+// Reject non-pow2 element count (5 * 32 = 160).
+typedef vint32m1_t five_elems __attribute__((riscv_rvv_vector_bits(160)));
+// expected-error at -1 {{invalid RVV vector size '160', the resulting element count '5' must be a power of 2}}

>From 067f675ea3e4fd9e9800804a5e4f23036fe54b07 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at sifive.com>
Date: Tue, 3 Nov 2026 13:44:23 +0800
Subject: [PATCH 3/3] fixup! [Clang][RISCV] Allow riscv_rvv_vector_bits
 typedefs shorter than VLEN*LMUL

x
---
 clang/docs/ReleaseNotes.md                           | 2 +-
 clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index ed34bed7df8604..e23a33637386a9 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -1328,7 +1328,7 @@ documentation](CIR/index.md) for more information regarding ClangIR's status and
   CPU will be selected from `-mcpu`.
 
 - `riscv_rvv_vector_bits(N)` now accepts any `N` up to `VLEN*LMUL` bits for
-  data types. For them it no longer requires `-mrvv-vector-bits`; without it,
+  data types. For them, it no longer requires `-mrvv-vector-bits`; without it,
   `VLEN` is the minimum required by `-march`. A shorter typedef keeps the LMUL
   of the type it was written against, and converts implicitly to and from that
   sizeless type (truncating, or leaving the upper lanes undefined).
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c b/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
index 807a83f68eb25d..72f90c6d6cfbc0 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits-no-flag.c
@@ -2,7 +2,7 @@
 // -mrvv-vector-bits=). The bound for riscv_rvv_vector_bits(N) on
 // a data type then comes from the ISA's Zvl*b extension, scaled by LMUL.
 //
-// Bound: N <= MinElts * EltSize * zvl / RVVBitsPerBlock = zvl * LMUL (bits)
+// Bound: N <= zvl * LMUL (bits)
 //
 // vintXm1_t  -> bound = zvl
 // vintXm2_t  -> bound = zvl * 2



More information about the llvm-branch-commits mailing list