https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113878

            Bug ID: 113878
           Summary: missed optimization with sanitizer and signed integer
                    overflow
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

It would be nice if the following example could be optimized better with the
sanitizer. Without sanitizer the function is optimized to return 1. With
sanitizer I would expect it to only add the test for the underflow condition,
but it then fails to optimize well.

int test(int x)
{
    if (x > 100)
        return 1;
    x -= 10;
    if (x > 100)
        return 2;
    return 1;
}

https://godbolt.org/z/j4K96v7jn

Reply via email to