[PATCH] D150360: [InstSimplify] Optimize compares with multiple selects as operands

Tejas Joshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 05:45:07 PDT 2023


tejas created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
tejas requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In case of a comparison with two select instructions having the same
condition, try to simplify the comparison by checking whether all
combinations of branches of the select result in the same value. Returns
the common value if so, otherwise returns null.
For example, if we have:
 %tmp1 = select i1 %cmp, i32 1, i32 %param
 %tmp2 = select i1 %cmp, i32 9, i32 %param
 %cmp2 = icmp slt i32 %tmp2, %tmp1
We can simplify %cmp2 to false, because both branches of both the selects
will result false.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150360

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/icmp-with-selects.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150360.521272.patch
Type: text/x-patch
Size: 4589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/64da9bb5/attachment.bin>


More information about the llvm-commits mailing list