------- Comment #29 from tkoenig at gcc dot gnu dot org 2009-08-15 09:22 ------- Subject: Re: Invariant DO loop variables and subroutines
On Sat, 2009-08-15 at 07:53 +0000, jv244 at cam dot ac dot uk wrote: > > ------- Comment #28 from jv244 at cam dot ac dot uk 2009-08-15 07:53 ------- > (In reply to comment #23) > > > subroutine output(i1,i2,i3,i4,i5) > > print '(5(I0,:" "))',i1,i2,i3,i4,i5 > > end subroutine output > > [..] > > > if (p1 * p2 * p3 * p4 == value * 1000000) & > > & call output(value,p1,p2,p3,p4) > [..] > > if (p1 * p2 * p3 * p4 == value * 1000000) & > > & call output((value),(p1),(p2),(p3),(p4)) > > still produces much better code. > > obviously this optimization is only allowed if the arguments of 'output' would > be explicitly declared intent in (or the compiler nows this, e.g. because it > is > an intrinsic or e.g. a write statement). It's the other way around: If output were to modify any of its arguments, the program would be illegal. Therefore, the compiler can assume that this doesn't happen. Intent(in) would be redundant for this particular case (though useful, so the compiler could easier detect errors). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31593