[PATCH] D134879: [InstSimplify] look through vector select (shuffle) in min/max fold

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 29 07:15:50 PDT 2022


spatel created this revision.
spatel added reviewers: nikic, RKSimon, dtemirbulatov.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is an extension of the existing min/max+select fold (which already has a very large number of variations) to allow a vector shuffle because that's what we have in the motivating example from issue #42100 <https://github.com/llvm/llvm-project/issues/42100>.

A couple of Alive2 checks of variants (I don't know how to generalize these in Alive):
https://alive2.llvm.org/ce/z/jUFAqT

And verify the PR42100 test:
https://alive2.llvm.org/ce/z/3EcASf

It's possible there is some generalization of the fold or a VectorCombine/SLP answer for the motivating test, but I haven't found a better/smaller solution yet. 
We can also add even more variants here as follow-up patches. For example, we can have shuffle followed by min/max; we also don't have this canonicalization or the reverse:
https://alive2.llvm.org/ce/z/StHD9f


https://reviews.llvm.org/D134879

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/select-maxmin.ll
  llvm/test/Transforms/PhaseOrdering/vector-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134879.463873.patch
Type: text/x-patch
Size: 9701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220929/bd92e866/attachment.bin>


More information about the llvm-commits mailing list