[llvm] [HLSL][NFC] Fix range check in verifyRegisterSpace (PR #152615)

Shafik Yaghmour via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 16:59:30 PDT 2025


https://github.com/shafik created https://github.com/llvm/llvm-project/pull/152615

Static analysis flagged the second part of this range check as always true. RegisterSpace is uint32_t therefore the max value is 0xFFFFFFFF and so the first check is sufficient.

>From 443762d928f353187b8aeec4c07e7415b59d67f8 Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghmour at intel.com>
Date: Thu, 7 Aug 2025 16:56:04 -0700
Subject: [PATCH] [HLSL][NFC] Fix range check in verifyRegisterSpace

Static analysis flagged the second part of this range check as always true.
RegisterSpace is uint32_t therefore the max value is 0xFFFFFFFF and so the
first check is sufficient.
---
 llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
index 9d84aa838f476..72308a3de5fd4 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
@@ -29,7 +29,7 @@ bool verifyRegisterValue(uint32_t RegisterValue) {
 // This Range is reserverved, therefore invalid, according to the spec
 // https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#all-the-values-should-be-legal
 bool verifyRegisterSpace(uint32_t RegisterSpace) {
-  return !(RegisterSpace >= 0xFFFFFFF0 && RegisterSpace <= 0xFFFFFFFF);
+  return !(RegisterSpace >= 0xFFFFFFF0);
 }
 
 bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {



More information about the llvm-commits mailing list