[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:54:28 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)) &&
----------------
gxyd wrote:

> You can't access operand 1 without confirming the opcode of RHS first to know that operand 1 exists.

True.

> The only opcode that has a VTSDNode operand is SIGN_EXTEND_INREG, but your test uses zeroext so I don't know where a SIGN_EXTEND_INREG would come from.

If we look at the SelectionDAG created here: https://github.com/llvm/llvm-project/issues/129401#issuecomment-3095273709, we do have the `operand(1)` of zeroext as a ValueType, and no node in the SelectionDAG has OpCode as SIGN_EXTEND_INREG.

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


More information about the llvm-commits mailing list