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

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 03:47:54 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)) &&
----------------
RKSimon wrote:

You shouldn't need to do anything involving VTSDNode - you would be better off confirming that:
```
VT.getScalarSizeInBits() > 1 &&
computeKnownBits(LHS).countMinLeadingZeros() >= (VT.getScalarSizeInBits() - 1) &&
computeKnownBits(RHS).countMinLeadingZeros() >= (VT.getScalarSizeInBits() - 1)
```

Also, you should be commenting what you are doing.

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


More information about the llvm-commits mailing list