[InstSimplify] Fold min/max intrinsic based on icmp of operands
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Aug 2020 19:58:25 +0000 (21:58 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Aug 2020 20:02:57 +0000 (22:02 +0200)
commitd7c119d89c5f6d0789cfd0a139c80e23912c0bb0
tree8f332f2c8e16a85bd068d387f81482f69c7b96fb
parentb73c5a0736fd6e42cf8ca7330cd4bb98aee6bcdc
[InstSimplify] Fold min/max intrinsic based on icmp of operands

This is a reboot of D84655, now performing the inner icmp
simplification query without undef folds.

It should be possible to handle the current foldMinMaxSharedOp()
fold based on this, by moving the logic into icmp of min/max instead,
making it more general. We can't drop the folds for constant operands,
because those also allow undef, which we exclude here.

The tests use assumes for exhaustive coverage, and have a few
more examples of misc folds we get based on icmp simplification.

Differential Revision: https://reviews.llvm.org/D85929
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll