[PATCH] D54237: Constant folding and instcombine for saturating adds
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 8 01:40:06 PST 2018
nikic added a comment.
Regarding
// X + undef -> undef
// undef + X -> undef
if (match(Op1, m_Undef()) || match(Op0, m_Undef()))
return UndefValue::get(ReturnType);
I was initially planning to include these simplifications, but ultimately was not certain regarding their legality. In particular, if we have uadd.sat(MaxValue, Y), then the result is fully determined to be MaxValue, regardless of the value of Y. If we have something like sadd.sat(SignedMinValue, Y) then the result is known to be negative. In either case the intrinsic cannot have the full range of results of the result type, regardless of the value of Y. As such, I think folding operations on undef to undef would not be legal in this case.
It should be possible to fold uadd.sat(X, undef) to MaxValue. Not sure how useful that is though.
Repository:
rL LLVM
https://reviews.llvm.org/D54237
More information about the llvm-commits
mailing list