[llvm] [DAG] optimize llvm.ucmp for 1-bit inputs to return subtraction of operands (PR #150058)

Gaurav Dhingra via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 04:55:57 PDT 2025


================
@@ -10942,6 +10942,10 @@ SDValue TargetLowering::expandCMP(SDNode *Node, SelectionDAG &DAG) const {
   SDValue IsLT = DAG.getSetCC(dl, BoolVT, LHS, RHS, LTPredicate);
   SDValue IsGT = DAG.getSetCC(dl, BoolVT, LHS, RHS, GTPredicate);
 
+  if (isa<VTSDNode>(RHS->getOperand(1)) &&
+      cast<VTSDNode>(RHS->getOperand(1))->getVT().getScalarSizeInBits() == 1) {
+    return DAG.getNode(ISD::SUB, dl, VT, LHS, RHS);
----------------
gxyd wrote:

Right. I'll fix that.

https://github.com/llvm/llvm-project/pull/150058


More information about the llvm-commits mailing list