[PATCH] D51398: [InstCombine] Fold (min/max ~X, Y) -> ~(max/min X, ~Y) when Y is freely invertible

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 11:52:41 PDT 2018


spatel added a comment.

In https://reviews.llvm.org/D51398#1219689, @craig.topper wrote:

> LHS/RHS are set based on the select operands not the compare operands aren't they?


Yes - sorry, I was looking at the start of matchSelectPattern() rather than matchMinMax(). Do you see a case where we would get the metadata wrong?

We should be canonicalizing harder and maybe that would bypass the question.
Ie, we shouldn't end up with a non-canonical min/max predicate like this:
%c = icmp ult i32 %x, %y
%max = select i1 %c, i32 %y, i32 %x


https://reviews.llvm.org/D51398





More information about the llvm-commits mailing list