[PATCH] D84655: [InstSimplify] fold min/max intrinsics using icmp simplification

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 13:04:53 PDT 2020


fhahn added a comment.

In D84655#2176704 <https://reviews.llvm.org/D84655#2176704>, @nikic wrote:

>> But (if my undef reasoning is correct), this is not as easy as always returning the existing operand. In the case of undefs, we need to clamp to the limit constant. This is similar to what we do with the saturating math intrinsics.
>
> In the longer term, I think we really need to introduce an InstSimplify query flag that disables undef-based folds. I think at this point we have multiple places where we need this. This is one, it is also the imho more proper solution to D84250 <https://reviews.llvm.org/D84250>, and @fhahn mentioned that this may be needed for NewGVN correctness as well.

For NewGVN we could also work around the problem by providing a way for InstSimplify to query the 'virtual' operands instead of the actual IR operands. I have some rough patches for that, but it gets quite hairy when it comes to threading that through to the various `match()` uses.

So for now, I put up a patch to control the use of undef through `SimplifyQuery` D84792 <https://reviews.llvm.org/D84792>. If it is useful in other cases too, it might make sense to get this in first.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84655/new/

https://reviews.llvm.org/D84655



More information about the llvm-commits mailing list