[PATCH] D87480: [InstCombine] Simplify select operand based on equality condition

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 13:24:55 PDT 2020


nikic created this revision.
nikic added reviewers: spatel, lebedev.ri, aqjune.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
nikic requested review of this revision.

For selects of the type `X == Y ? A : B`, check if we can simplify `A` by using the `X == Y` equality and replace the operand if that's possible. We already try to do this in InstSimplify, but will only fold if the result of the simplification is the same as `B`, in which case the select can be dropped entirely. Here the select will be retained, just one operand simplified.

As we are performing an actual replacement here, we don't have problems with refinement / poison values.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87480

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/rem.ll
  llvm/test/Transforms/InstCombine/select-binop-cmp.ll
  llvm/test/Transforms/InstCombine/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87480.291073.patch
Type: text/x-patch
Size: 7393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/aaecb150/attachment-0001.bin>


More information about the llvm-commits mailing list