[llvm] [DAG] ComputeNumSignBits - add ISD::SCMP/UCMP handling (PR #153805)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 15 06:28:05 PDT 2025


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/153805

None

>From f3b9878b724e6ed0d3ccebfe8ebd739a340e5cdc Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Fri, 15 Aug 2025 14:27:19 +0100
Subject: [PATCH] [DAG] ComputeNumSignBits - add ISD::SCMP/UCMP handling

---
 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 4b7fc45908119..9db91f621ffb6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4999,6 +4999,11 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
         TargetLowering::ZeroOrNegativeOneBooleanContent)
       return VTBits;
     break;
+  case ISD::SCMP:
+  case ISD::UCMP:
+    // Returns -1/0/1 with i2 type or larger.
+    assert(VTBits >= 2 && "Result type not large enough for SCMP/UCMP node");
+    return VTBits - 1;
   case ISD::SETCC:
   case ISD::SETCCCARRY:
   case ISD::STRICT_FSETCC:



More information about the llvm-commits mailing list