[PATCH] D107148: [InstCombine] Fold two-value clamp patterns

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 30 03:27:20 PDT 2021


qiucf created this revision.
qiucf added reviewers: spatel, xbolva00, RKSimon, mkazantsev, dmgreen.
Herald added a subscriber: hiraditya.
qiucf requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is for PR43053 <https://bugs.llvm.org/show_bug.cgi?id=43053>, the following pattern:

  %cmp1 = icmp slt i32 %num, C1
  %s1 = select i1 %cmp1, i32 %num, i32 C1
  %cmp2 = icmp sgt i32 %s1, C2
  %r = select i1 %cmp2, i32 %s1, i32 C2
  ; C2 = C1 - 1

can be folded into

  %cmp3 = icmp sgt %num, C2
  %z = zext i1 %cmp3 to i32
  %r = add i32 %z, C2


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107148

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/icmp-dom.ll
  llvm/test/Transforms/InstCombine/minmax-fold.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107148.363020.patch
Type: text/x-patch
Size: 6020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210730/555f0df5/attachment.bin>


More information about the llvm-commits mailing list