This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Language-independent functions-as-trees representation


Op zo 21-07-2002, om 07:17 schreef Richard Henderson:
> On Sat, Jul 20, 2002 at 10:09:53PM +0200, Steven Bosscher wrote:
> > Once we've generated SIMPLE code, we've lost the opportunity to do this
> > kind of inlining.
> 
> Err, why?

Because at that point:
- we have already created the temporary arrays and the code to copy 
  in/out the array
- we have already scalarized nonzero rank assignments

SIMPLE doesn't know about array syntax, and Fortran 95 does, remember?

A trivial example:

program could_inline
real, dimension(20) :: a,b,c
a = foo(b+c) ! of course b and c would be defined before this
stop

contains
	function foo(x) result (y)
	   real, dimension(:), intent (in) :: x
	   real, dimension(:), intent (out) :: y
	   y = x
	end function foo
end

Obvioulsy the function is trivial enough that it could be inlined. But
once we have generated SIMPLE, the actual argument 'b+c' is evaluated
and put in a temporary array before we do the call.

So instead of generating SIMPLE for:

program could_inline
real, dimension(20) :: a,b,c
a = b+c
stop

we would have to produde the SIMPE equivalent for something like:

program could_inline
real, dimension(20) :: a,b,c
tmp1 = b+c ! tmp1 declared locally in PRE chain of the call stmt
call foo(a, tmp1)
stop

contains
	subroutine foo(y,x)
	   real, dimension(:), intent (in) :: x
	   real, dimension(:), intent (out) :: y
	   y = x
	end subroutine foo
end

Greetz
Steven



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]