[PATCH] D41136: [EarlyCSE] recognize commuted and swapped variants of min/max as equivalent (PR35642)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 17 08:43:31 PST 2017
spatel added a comment.
In https://reviews.llvm.org/D41136#955784, @spatel wrote:
> > It seems like there are cases missing here (e.g., this does not apply only to the GE/LE predicates)? Based on your example, it seems like we have the same problem with the GT/LT predicates.
>
> Yep - that's the quick fix; add the other preds. A better solution might be to distinguish signed zero behavior in the same way that we're doing for NAN. But let me try the easy patch first and see if anything breaks. :)
Unfortunately, we would regress this test:
define i8 @t9(float %a) {
%t1 = fcmp ult float %a, 0.0
%t2 = fptosi float %a to i8
%t3 = select i1 %t1, i8 %t2, i8 0
ret i8 %t3
}
Currently, we recognize that as fmin with a cast and canonicalize to:
define i8 @t9(float %a) {
%.inv = fcmp oge float %a, 0.0
%t31 = select i1 %.inv, float 0.0, float %a
%1 = fptosi float %t31 to i8
ret i8 %1
}
We could set the 'nsz' bit that we're sending to the matcher to avoid the regression in the case of a min/max with cast.
Repository:
rL LLVM
https://reviews.llvm.org/D41136
More information about the llvm-commits
mailing list