[PATCH] Improve -fsanitize=undefined a little bit

Jakub Jelinek jakub@redhat.com
Thu Dec 5 11:58:00 GMT 2013


On Thu, Dec 05, 2013 at 12:51:09PM +0100, Jakub Jelinek wrote:
> For ubsan_expand_si_overflow_neg_check, I think tree-vrp.c change can be
> improved to handle also anti ranges, if the first argument of
> UBSAN_CHECK_SUB has value range [0, 0] and second argument anti-range
> ~[x, y] where x is minimum, then it will also never overflow.  Though,
> I wonder if VRP doesn't canonicalize say ~[INT_MIN, INT_MIN] into
> [INT_MIN+1, INT_MAX].

That would be
int
fn9 (int x)
{
  if (x == -__INT_MAX__-1)
    return x;
  return -x;
}
I guess, but the VR is then canonicalized properly, so we optimize
away the UBSAN_CHECK_SUB into negation.  Strangely, we don't
actually optimize it, neither at gimple level or rtl level into
(int) -(unsigned) x;

	Jakub



More information about the Gcc-patches mailing list