[PATCH] D67800: [InstCombine] Fold a shifty implementation of clamp (e.g., clamp255).

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 23:37:30 PDT 2019


huihuiz created this revision.
huihuiz added reviewers: lebedev.ri, efriedma, spatel, kparzysz, bcahoon.
huihuiz added a project: LLVM.
Herald added subscribers: hiraditya, kristof.beyls.

Fold

  or(ashr(sub(C, V), ScalarSizeInBits - 1), V)

into

  V s> C ? AllOnesValue : V

where sub hasNoSignedWrap.

clamp255 as common operator for image processing, can be implemented
in a shifty way "(255 - V) >> 31 | V & 255". Fold shift into select
enables more optimization, e.g., vmin generation for ARM target.

https://rise4fun.com/Alive/Aji


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67800

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67800.220955.patch
Type: text/x-patch
Size: 7126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190920/8d652476/attachment.bin>


More information about the llvm-commits mailing list