[PATCH] D108049: [InstCombine] Canonicalize saturate with shift and xor to min/max clamp

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 31 10:25:36 PDT 2021


dmgreen added a comment.

In D108049#2974587 <https://reviews.llvm.org/D108049#2974587>, @spatel wrote:

> That's a big fold! 
> The larger the pattern match, the more fragile the optimization tends to be because we might eventually find sub-patterns that can be reduced.

Yeah OK, Sounds good. I'll try it as a number of smaller folds, like you say it should be more reliable and that way the final pattern should at least be smaller. I half remember from a very long time ago trying the same thing (including extends/add to make a sadd.sat pattern), but couldn't do it without some combines that individually increased instruction count (or large combines).

I can give it another go though. From looking at it again, this gets us there, but the last fold involves moving truncates in the wrong direction:
https://godbolt.org/z/dKjdfhe1s

I'll try and figure out if there's anything more sensible to do as that last fold. Suggestions welcome if you have any :)


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

https://reviews.llvm.org/D108049



More information about the llvm-commits mailing list