[llvm] [TargetLowering] Optimize scmp with 0 using (x ashr 31) | (-x shr 31) (PR #205398)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 04:37:44 PDT 2026


================
@@ -12563,11 +12563,25 @@ SDValue TargetLowering::expandCMP(SDNode *Node, SelectionDAG &DAG) const {
   unsigned Opcode = Node->getOpcode();
   SDValue LHS = Node->getOperand(0);
   SDValue RHS = Node->getOperand(1);
+
   EVT VT = LHS.getValueType();
   EVT ResVT = Node->getValueType(0);
-  EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
   SDLoc dl(Node);
 
+  if (Opcode == ISD::SCMP && isNullConstant(RHS) && preferBitwiseSignum()) {
----------------
RKSimon wrote:

Any success in remove the new hook? Does preferSelectsOverBooleanArithmetic work for instance?

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


More information about the llvm-commits mailing list