Currently we drop wrapping flags for expressions like (A + C1)<flags> - C2.
If C1 >= 0, C2 >= 0 and C1 >= C2, we should be able to fold (C1 - C2),
which will be >= 0 && <= C1, so we should be able to retain the flags of
the original expression. The key here is that we fold (C1 - C2) to a
non-negative constant.
I would appreciate a careful look in case I am missing a case. The logic
at the moment is quite specialized, do you think this could/should be
generalized?
This can improve results after using SimplifyICmpOperands, which may
subtract one in order to use stricter predicates, as is the case for
isKnownPredicate.
Simple example with Alive2. Not how to best construct an example without
concrete constants.