[PATCH] D108049: [InstCombine] Canonicalize saturate with shift and xor to min/max clamp
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 11:59:38 PDT 2021
dmgreen created this revision.
dmgreen added reviewers: spatel, efriedma, lebedev.ri, RKSimon, nikic.
Herald added a subscriber: hiraditya.
dmgreen requested review of this revision.
Herald added a project: LLVM.
This takes sequences of shift/xor/truncates that together perform a saturate, but a difficult to analyze, and canonicalizes them to min(max(..)) patterns in instcombine.
https://alive2.llvm.org/ce/z/rXLTv8
This is now less instructions (whether you count them as min/max , and with an extra addition can potentially be folded into a sadd.sat. The matched sequence is fairly big but I've not managed to simplify it in smaller steps, so this does it all at once. The code to match it is fairly concise, but it can be moved to aggressive instcombine if that is preferable.
https://reviews.llvm.org/D108049
Files:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/truncating-saturate.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108049.366325.patch
Type: text/x-patch
Size: 14526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210813/fa909298/attachment.bin>
More information about the llvm-commits
mailing list