llvm-project
f16dbe0e - [SelectionDAG] Don't always use abs(sub) when expanding abdu (#235043)

Commit
4 days ago
[SelectionDAG] Don't always use abs(sub) when expanding abdu (#235043) `TargetLowering::expandABD` expands `abd(a, b)` to `abs(sub(a, b))` when `willNotOverflowSub` says the sub can't overflow. For `abdu` without known non-negative operands, this checks for unsigned overflow, which only proves `a >= b (unsigned)`, so `abdu(a, b) == sub(a, b)`. adding abs around it is wrong, when the difference is greater than INT_MAX, e.g. `abdu(lshr(x, 1), or(y, INT_MIN))`. Keep abs(sub) for the signed check (abds, or abdu with non-negative operands) and use just sub when abdu and `a >= b`. Fixes #233087.
Author
Parents
Loading