[PATCH] D54237: Constant folding and instcombine for saturating adds

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 11 03:04:13 PST 2018


bjope added a comment.

In https://reviews.llvm.org/D54237#1294571, @nikic wrote:

> > Is it perhaps "better" to fold `sadd_sat(X, undef) -> 0` And `uadd_sat(X, undef) -> MaxValue` if we want to get rid of undef here? That way we get rid of the X operand as well.
>
> Folding `sadd_sat(X, undef) -> 0` would not be valid, because if `X = SignedMinValue`, there is no choice of `undef` for which the result would be zero. The largest value that can be reached is `-1`.


Ok. Got it! Sorry for the confusion.

Btw, thanks for adding these new folds of saturating add/sub.


https://reviews.llvm.org/D54237





More information about the llvm-commits mailing list