[patch, fortran] Two tweaks to argument repacking

Thomas Koenig tkoenig@netcologne.de
Sun Jun 2 13:34:00 GMT 2019


Hello world,

this patch adds two tweaks to the argument repacking.

First, when the size of an argument is known to be one, as in a(n1:n1),
we can directly pass a pointer - the stride may not be one, but it
does not matter.

Second, the case where the array passed is actually contiguous is
more likely in practice, so it should get the fast path. I have
done this by defining a new predictor and setting the estimated
likelyhood at 75%, which ensured a path without jumps when the
arguments passed to bar were contiguous:

module y
contains
   subroutine bar(a,b)
     real, dimension(:) :: a,b
     call foo(a,b,size(a))
   end subroutine bar
end module y

Test case is only for the first part - making one for the second
part would have been a bit too much.

Regression-tested. OK for trunk?

Regards

	Thomas

2019-06-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/90539
	* trans-expr.c (gfc_conv_subref_array_arg): If the size of the
	expression can be determined to be one, treat it as contiguous.
	Set likelyhood of presence of an actual argument according to
	PRED_FORTRAN_ABSENT_DUMMY and likelyhood of being contiguous
	according to PRED_FORTRAN_CONTIGUOUS.

2019-06-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/90539
	* predict.def (PRED_FORTRAN_CONTIGUOUS): New predictor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p5a.diff
Type: text/x-patch
Size: 3747 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190602/4b7371d0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: internal_pack_24.f90
Type: text/x-fortran
Size: 812 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190602/4b7371d0/attachment-0001.bin>


More information about the Fortran mailing list