[llvm] [X86] checkSignTestSetCCCombine - remove early return in CMP(X,0) case (PR #178710)

Abhiram Jampani via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 30 11:09:20 PST 2026


https://github.com/Abhiramjampani updated https://github.com/llvm/llvm-project/pull/178710

>From d5ae5c5ff342186a7e58a8310be93c3878ecf52d Mon Sep 17 00:00:00 2001
From: Abhiramjampani <lcs2022059 at iiitl.ac.in>
Date: Thu, 29 Jan 2026 23:17:06 +0530
Subject: [PATCH] [X86] checkSignTestSetCCCombine - extend CMP(X,0) to handle
 SHL/SIGN_EXTEND_INREG

---
 llvm/lib/Target/X86/X86ISelLowering.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 144d6451b981f..58dde922731a1 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -48975,12 +48975,16 @@ static SDValue checkSignTestSetCCCombine(SDValue Cmp, X86::CondCode &CC,
     if (!isNullConstant(Cmp.getOperand(1)))
       return SDValue();
     Src = Cmp.getOperand(0);
-    // Peek through a SRA node as we just need the signbit.
     // TODO: Remove one use limit once sdiv-fix regressions are fixed.
-    // TODO: Use SimplifyDemandedBits instead of just SRA?
-    if (Src.getOpcode() != ISD::SRA || !Src.hasOneUse())
+    if (!Src.hasOneUse())
+      return SDValue();
+    // Peek through a SRA node as we just need the signbit.
+    // TODO: Use SimplifyMultipleUseDemandedBits instead of just SRA?
+    if (Src.getOpcode() == ISD::SRA)
+      Src = Src.getOperand(0);
+    else if (Src.getOpcode() != ISD::SHL &&
+             Src.getOpcode() != ISD::SIGN_EXTEND_INREG)
       return SDValue();
-    Src = Src.getOperand(0);
   } else if (Cmp.getOpcode() == X86ISD::OR) {
     // OR(X,Y) -> see if only one operand contributes to the signbit.
     // TODO: XOR(X,Y) -> see if only one operand contributes to the signbit.



More information about the llvm-commits mailing list