[llvm] [KnownBits] Make abdu and abds optimal (PR #89081)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 03:16:52 PDT 2024
================
@@ -232,41 +232,53 @@ KnownBits KnownBits::smin(const KnownBits &LHS, const KnownBits &RHS) {
}
KnownBits KnownBits::abdu(const KnownBits &LHS, const KnownBits &RHS) {
- // abdu(LHS,RHS) = sub(umax(LHS,RHS), umin(LHS,RHS)).
- KnownBits UMaxValue = umax(LHS, RHS);
- KnownBits UMinValue = umin(LHS, RHS);
- KnownBits MinMaxDiff = computeForAddSub(/*Add=*/false, /*NSW=*/false,
- /*NUW=*/true, UMaxValue, UMinValue);
+ // If we know which argument is larger, return (sub LHS, RHS) or
+ // (sub RHS, LHS) directly.
+ if (LHS.getMinValue().uge(RHS.getMaxValue()))
+ return computeForAddSub(/*Add=*/false, /*NSW=*/false, /*NUW=*/false, LHS,
+ RHS);
+ if (RHS.getMinValue().uge(LHS.getMaxValue()))
+ return computeForAddSub(/*Add=*/false, /*NSW=*/false, /*NUW=*/false, RHS,
+ LHS);
----------------
RKSimon wrote:
So should we provide an internal version of computeForAddSub "computeForAddSub_internal?" that doesn't clear out conflicts and have computeForAddSub wrap that?
https://github.com/llvm/llvm-project/pull/89081
More information about the llvm-commits
mailing list