[Bug middle-end/49733] Missed optimization: Variable value not propagated to remove "if" condition

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 13 14:18:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49733

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-13 14:17:38 UTC ---
is

  program test

  integer :: a

  subroutine bar()
  a = 1
  end

  subroutine sub(non_aliasing_var)
  integer :: non_aliasing_var
  non_aliasing_var = 5
  bar()
  if (non_aliasing_var /= 5) call foobar()
  end

  sub(a)
  end

invalid then?  GCC assumes that any function can modify any global
variable unless interprocedural analysis can prove otherwise.

It gets more interesting when you consider

  subroutine sub(non_aliasing_var)
  integer :: non_aliasing_var
  non_aliasing_var = 5
  sub(a)
! or even
! sub (non_aliasing_var)
  if (non_aliasing_var /= 5) call foobar()
  end

(or even hide the recursion by going through an external dispatcher)

Does that make the variable "aliased"?  Or is that invalid as well
(ok, add whatever is required to allow sub be called recursively - what then?)



More information about the Gcc-bugs mailing list