diff options
author | AZero13 <gfunni234@gmail.com> | 2025-09-24 21:33:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-25 10:33:05 +0900 |
commit | 151a80bbcea947a097870e8ce9034583936a357b (patch) | |
tree | 89bc20ed6e920f84be5ab1654f410f6877454e1f /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | a3d7c468bdc328f04da720088b2e542ef1f33ffc (diff) | |
download | llvm-151a80bbcea947a097870e8ce9034583936a357b.zip llvm-151a80bbcea947a097870e8ce9034583936a357b.tar.gz llvm-151a80bbcea947a097870e8ce9034583936a357b.tar.bz2 |
[TargetLowering][ExpandABD] Prefer selects over usubo if we do the same for ucmp (#159889)
Same deal we use for determining ucmp vs scmp.
Using selects on platforms that like selects is better than using usubo.
Rename function to be more general fitting this new description.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 80500e4..4145c8a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -9775,11 +9775,12 @@ SDValue TargetLowering::expandABD(SDNode *N, SelectionDAG &DAG) const { return DAG.getNode(ISD::SUB, dl, VT, Cmp, Xor); } - // Similar to the branchless expansion, use the (sign-extended) usubo overflow - // 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)) { + // Similar to the branchless expansion, if we don't prefer selects, use the + // (sign-extended) usubo overflow 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) && + !preferSelectsOverBooleanArithmetic(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)); @@ -10974,7 +10975,8 @@ SDValue TargetLowering::expandCMP(SDNode *Node, SelectionDAG &DAG) const { // because one of the conditions can be merged with one of the selects. // And finally, if we don't know the contents of high bits of a boolean value // we can't perform any arithmetic either. - if (shouldExpandCmpUsingSelects(VT) || BoolVT.getScalarSizeInBits() == 1 || + if (preferSelectsOverBooleanArithmetic(VT) || + BoolVT.getScalarSizeInBits() == 1 || getBooleanContents(BoolVT) == UndefinedBooleanContent) { SDValue SelectZeroOrOne = DAG.getSelect(dl, ResVT, IsGT, DAG.getConstant(1, dl, ResVT), |