[llvm] [TableGen][RISCV] Avoid using operator< on bools in SearchableTable lookup functions. (PR #182553)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 20 09:48:43 PST 2026


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/182553

Hoping this makes MSVC happy.

Fixes #182485.

>From 33d7d9225151d3fd114c70239286b19302d7fa48 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Fri, 20 Feb 2026 09:45:22 -0800
Subject: [PATCH] [TableGen][RISCV] Avoid using operator< on bools in
 SearchableTable lookup functions.

Hoping this makes MSVC happy.

Fixes #182485.
---
 llvm/utils/TableGen/SearchableTableEmitter.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 88aa6bf8e9242..7dde130a9222a 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -491,6 +491,11 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
         OS << "      if ((unsigned)LHS." << Field.Name << " > (unsigned)RHS."
            << Field.Name << ")\n";
         OS << "        return false;\n";
+      } else if (isa<BitRecTy>(Field.RecType)) {
+        // Avoid using operator< on bools to silence MSVC warning.
+        OS << "      if (LHS." << Field.Name << " != RHS." << Field.Name
+           << ")\n";
+        OS << "        return RHS." << Field.Name << ";\n";
       } else {
         OS << "      if (LHS." << Field.Name << " < RHS." << Field.Name
            << ")\n";



More information about the llvm-commits mailing list