[PATCH] D51398: [InstCombine] Fold (neg (min/max ~X, C)) -> (add (min/max X, ~C), 1)

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 18:21:57 PDT 2018


craig.topper created this revision.
craig.topper added reviewers: spatel, lebedev.ri.

Negate is equivalent to (add (xor X, -1), 1), so can pull out the (xor X, -1) part and use it to rewrite a min/max with an inverted input where the other operand can be freely inverted. Theoretically this could be extended to other subtracts than just a negate.


https://reviews.llvm.org/D51398

Files:
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  test/Transforms/InstCombine/sub.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51398.163002.patch
Type: text/x-patch
Size: 4763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/4d4a0881/attachment.bin>


More information about the llvm-commits mailing list