[PATCH] D69252: [InstCombine] Canonicalize sadd.with.overflow to sadd.sat

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 05:57:45 PDT 2019


dmgreen created this revision.
dmgreen added reviewers: nikic, lebedev.ri, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This adds to D69245 <https://reviews.llvm.org/D69245>, adding extra signed patterns for folding from a sadd_with_overflow or ssub_with_overflow to a sadd_sat or a ssub_sat. These are more complex than the unsigned patterns, as the overflow can occur in either direction.

For the add case, the positive overflow can only occur if both of the values are positive (same for both the values being negative). So there is an extra select on whether to use the positive or negative overflow limit. For negatives the subtracted value behaves the other way, and there is the added complication of subtracting 0x80 from 0, changing the compare bounds slightly.


https://reviews.llvm.org/D69252

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/overflow_to_sat.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69252.225861.patch
Type: text/x-patch
Size: 17423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191021/b443247b/attachment.bin>


More information about the llvm-commits mailing list