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

            Bug ID: 89143
           Summary: [9 Regression] comparison of abs(i) against excessive
                    constant less than UXXX_MAX no longer folded
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While looking into bug 89127 I noticed that while GCC 8 and prior fold the
comparison to false in the if controlling expression below due to the limited
range of i's type, GCC 9 no longer performs this folding unless the constant is
 UCHAR_MAX and greater.  Same for short and SHRT_MAX + 1.

$ cat u.c && gcc -S -O2 -Wall -Wextra -Wtype-limits
-fdump-tree-optimized=/dev/stdout u.c
void f (signed char i)
{
  if (__builtin_abs (i) > 128)
    __builtin_abort ();
}

;; Function f (f, funcdef_no=0, decl_uid=1906, cgraph_uid=1, symbol_order=0)

f (signed char i)
{
  unsigned char _1;

  <bb 2> [local count: 1073741824]:
  _1 = ABSU_EXPR <i_2(D)>;
  if (_1 > 128)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_abort ();

  <bb 4> [local count: 1073741824]:
  return;

}

Reply via email to