[PATCH] D27531: [InstCombine] add folds for icmp (smin X, Y), X

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 11:33:52 PST 2016


spatel created this revision.
spatel added reviewers: efriedma, majnemer, jmolloy.
spatel added subscribers: volkan, llvm-commits.
Herald added a subscriber: mcrosier.

As Volkan noted in the commit thread for https://reviews.llvm.org/rL287585, min/max canonicalization exposes the fact that we're missing combines for min/max patterns. This patch won't solve the example that was attached to that thread, so something else still needs fixing.

The line between InstCombine and InstSimplify gets blurry here because sometimes the icmp instruction that we want to fold to already exists, but sometimes it's the swapped form of what we want.

Also note that there's yet another definition of min/max via the matcher patterns (I didn't find these until recently). I'm still hoping to canonicalize the non-standard patterns detected by matchSelectPattern(), so I went ahead and used m_SMin here even though I think that means those non-standard patterns will fall through for now.

Once this looks ok, I can follow up with the corresponding smax/umin/umax.


https://reviews.llvm.org/D27531

Files:
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h
  test/Transforms/InstCombine/smin-icmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27531.80630.patch
Type: text/x-patch
Size: 7973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/9c5869ca/attachment.bin>


More information about the llvm-commits mailing list