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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
             Blocks|49774                       |
         Resolution|---                         |INVALID

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test case in comment #0 cannot be optimized as suggested because *q can be
equal to NaN.  Replacing the (unfortunately chosen) double with some other type
like long shows that the expected optimization is done as expected.

$ cat pr93970.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout pr93970.c
void f (int *__restrict p, int *__restrict q)
{
  int t = *q;
  *p = 0;
  if (t != *q)            // folded to false
    __builtin_abort ();
}

void g (int *__restrict p, long *__restrict q)
{ 
  long t = *q;
  *p = 0;
  if (t != *q)            // also folded as expected
    __builtin_abort ();
}

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

f (int * restrict p, int * restrict q)
{
  <bb 2> [local count: 1073741824]:
  *p_3(D) = 0;
  return;

}



;; Function g (g, funcdef_no=3, decl_uid=1936, cgraph_uid=2, symbol_order=1)

g (int * restrict p, long int * restrict q)
{
  <bb 2> [local count: 1073741824]:
  *p_2(D) = 0;
  return;

}


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49774
[Bug 49774] [meta-bug] restrict qualification aliasing issues

Reply via email to