[llvm] [RISCV] Omit VTYPE in VSETVLIInfo::print() when state is uninit or unknown. (PR #169459)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 07:27:02 PST 2025


https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/169459

>From 6936611d2f9cd3b90611d9b22bb3de73fb86e9db Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 24 Nov 2025 22:21:32 -0800
Subject: [PATCH 1/2] [RISCV] Omit VTYPE in VSETVLIInfo::print() when state is
 uninit or unknown.

---
 llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 38 ++++++++++----------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 2ddc9b0adb9e1..418525ea4017f 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -837,7 +837,7 @@ class VSETVLIInfo {
   /// Implement operator<<.
   /// @{
   void print(raw_ostream &OS) const {
-    OS << "{";
+    OS << '{';
     switch (State) {
     case Uninitialized:
       OS << "Uninitialized";
@@ -855,24 +855,26 @@ class VSETVLIInfo {
       OS << "AVLVLMAX";
       break;
     }
-    OS << ", ";
+    if (State != Uninitialized && State != Unknown) {
+      OS << ", ";
+
+      unsigned LMul;
+      bool Fractional;
+      std::tie(LMul, Fractional) = decodeVLMUL(VLMul);
+
+      OS << "VLMul=m";
+      if (Fractional)
+        OS << 'f';
+      OS << LMul << ", "
+         << "SEW=e" << (unsigned)SEW << ", "
+         << "TailAgnostic=" << (bool)TailAgnostic << ", "
+         << "MaskAgnostic=" << (bool)MaskAgnostic << ", "
+         << "SEWLMULRatioOnly=" << (bool)SEWLMULRatioOnly << ", "
+         << "TWiden=" << (unsigned)TWiden << ", "
+         << "AltFmt=" << (bool)AltFmt;
+    }
 
-    unsigned LMul;
-    bool Fractional;
-    std::tie(LMul, Fractional) = decodeVLMUL(VLMul);
-
-    OS << "VLMul=";
-    if (Fractional)
-      OS << "mf";
-    else
-      OS << "m";
-    OS << LMul << ", "
-       << "SEW=e" << (unsigned)SEW << ", "
-       << "TailAgnostic=" << (bool)TailAgnostic << ", "
-       << "MaskAgnostic=" << (bool)MaskAgnostic << ", "
-       << "SEWLMULRatioOnly=" << (bool)SEWLMULRatioOnly << ", "
-       << "TWiden=" << (unsigned)TWiden << ", "
-       << "AltFmt=" << (bool)AltFmt << "}";
+    OS << '}';
   }
 #endif
 };

>From ef22b83b15d32031e087d12e135bcf7b95b348a1 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 25 Nov 2025 07:26:49 -0800
Subject: [PATCH 2/2] fixup! Fix build failure

---
 llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index e46365b796346..0dfffc7fd1430 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -855,7 +855,7 @@ class VSETVLIInfo {
       OS << "AVLVLMAX";
       break;
     }
-    if (State != Uninitialized && State != Unknown) {
+    if (isValid() && !isUnknown()) {
       OS << ", ";
 
       unsigned LMul;



More information about the llvm-commits mailing list