[PATCH] D69514: [InstCombine] Expand usub_sat patterns to handle constants

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 12:46:13 PST 2019


dmgreen marked 2 inline comments as done.
dmgreen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:707
 
   // Account for swapped form of subtraction: ((a > b) ? b - a : 0).
+  // Checking for both a-b and a+(-b) as a constant.
----------------
lebedev.ri wrote:
> I'm having doubt about the comment.
> If `b < a`, then `b - a` will wrap, and we'll return wrapped result.
> And if `b >= a`, then `b - a` will **not** wrap, but we will saturate to `0`.
> What am i missing?
>From the comment below, this looks like it is referring to
`(a > b) ? b - a : 0 -> -usub.sat(a, b)`
I'll try and update it to be clearer.


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

https://reviews.llvm.org/D69514





More information about the llvm-commits mailing list