[PATCH] D60061: [InstCombine] ssubo X, C -> saddo X, -C

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 1 09:48:28 PDT 2019


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:2161
+    if (match(Arg1, m_APInt(C)) &&
+        !(C->isMinSignedValue() || C->isMaxSignedValue())) {
+      // Create a copy of the original constant and negate it.
----------------
RKSimon wrote:
> Is C->isMaxSignedValue() necessary?
Checking for max signed value is not necessary, as `-SignedMax` doesn't overflow, only `-SignedMin` does.

For parity with `ssub.sat` canonicalization I'd suggest to use the same implementation here, which will also handle non-splat vector constants:

```
Constant *C;
if (match(Arg1, m_Constant(C)) && C->isNotMinSignedValue()) {
    Value *NegVal = ConstantExpr::getNeg(C);
    // Create ssubo with NegVal here.
}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60061/new/

https://reviews.llvm.org/D60061





More information about the llvm-commits mailing list