[llvm] [TargetLowering] Don't do abdu(lhs, rhs) -> sub(xor(sub(lhs, rhs), uo…f(lhs, rhs)), uof(lhs, rhs)) if it is not custom lowered (PR #156188)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 30 09:19:03 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

<details>
<summary>Changes</summary>

Otherwise we deal with a lot of crazy expansions that could be handled by a select.

---
Full diff: https://github.com/llvm/llvm-project/pull/156188.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 402a012e8e555..9a7379032766a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -9792,7 +9792,8 @@ SDValue TargetLowering::expandABD(SDNode *N, SelectionDAG &DAG) const {
   // flag if the (scalar) type is illegal as this is more likely to legalize
   // cleanly:
   // abdu(lhs, rhs) -> sub(xor(sub(lhs, rhs), uof(lhs, rhs)), uof(lhs, rhs))
-  if (!IsSigned && VT.isScalarInteger() && !isTypeLegal(VT)) {
+  if (!IsSigned && VT.isScalarInteger() && !isTypeLegal(VT) &&
+      isOperationCustom(ISD::USUBO, VT)) {
     SDValue USubO =
         DAG.getNode(ISD::USUBO, dl, DAG.getVTList(VT, MVT::i1), {LHS, RHS});
     SDValue Cmp = DAG.getNode(ISD::SIGN_EXTEND, dl, VT, USubO.getValue(1));

``````````

</details>


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


More information about the llvm-commits mailing list