[PATCH] D65576: [InstCombine] simplify a cmp+select using binop result equivalence

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 07:16:51 PDT 2019


spatel created this revision.
spatel added reviewers: lebedev.ri, nikic, craig.topper.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

As discussed in PR42696:
https://bugs.llvm.org/show_bug.cgi?id=42696
...but won't help that case yet.

We have an odd situation where a select equivalence fold was implemented in InstSimplify when it could have been done more generally in InstCombine if we allow dropping of {nsw,nuw,exact} from a binop operand.

Here's an example:
https://rise4fun.com/Alive/Xplr

  %cmp = icmp eq i32 %x, 2147483647
  %add = add nsw i32 %x, 1
  %sel = select i1 %cmp, i32 -2147483648, i32 %add
  =>
  %sel = add i32 %x, 1

I've left the InstSimplify code in place for now, but my guess is that we'd prefer to remove that as a follow-up to save on code duplication and compile-time.


https://reviews.llvm.org/D65576

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/select-bitext-bitwise-ops.ll
  llvm/test/Transforms/InstCombine/select-obo-peo-ops.ll
  llvm/test/Transforms/InstCombine/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65576.212802.patch
Type: text/x-patch
Size: 49640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/45b0638b/attachment.bin>


More information about the llvm-commits mailing list