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

--- Comment #13 from Martin Sebor <msebor at gcc dot gnu.org> ---
As noted in the duplicate pr90122, the test case below shows that GCC already
relies on different extern declarations denoting distinct objects.  It just
doesn't fold the address equality expression for some reason.

$ cat x.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout
-fno-common x.c
extern int a, b;

void foo ();
void bar ();

void f (void)
{
  if (&a == &b)   // not folded
    foo ();

  int i = a;
  b = 0;
  if (i != a)     // folded to false
    bar ();
}

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

Removing basic block 5
f ()
{
  <bb 2> [local count: 1073741824]:
  if (&a == &b)
    goto <bb 3>; [17.43%]
  else
    goto <bb 4>; [82.57%]

  <bb 3> [local count: 187153200]:
  foo ();

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

}

Reply via email to