This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/29543] Poor code generated for arrays with variable bounds



------- Comment #8 from jeff at thecreems dot com  2006-10-22 15:50 -------
(In reply to comment #7)
> > No, but there is an obvious one why the Fortran version trounces the Ada
> > version.  Let's not compare apples with oranges.
> 
> The adverse effect of the indirection can be alleviated though:
> 
>    N : Positive := Positive'Value (Argument (1));
>    G : Ada.Numerics.Float_Random.Generator;
> 
>    type Real_Matrix is array (1..N, 1..N) of Float;
>    type Matrix_Access is access Real_Matrix;
> 
>    A,B,C : Matrix_Access;
>    Start, Finish : Ada.Calendar.Time;
>    Sum : Float := 0.0;
> begin
>    A := new Real_Matrix;
>    B := new Real_Matrix;
>    C := new Real_Matrix;
> 


That is a good approach and it significantly narrows the gap though I would
argue that a general user would not see the original version as "different"
than the FORTRAN version. Both of them are dynamically allocating the size at
run time based on an input parameter. The FORTRAN arrays could indeed be passed
to other procedures (such as matmul) that take variable sized arrays while this
modified version (in its current form) could not.

So, from an understanding of the internals of the compiler, I think you have a
reasonable argument that the original Ada and FORTRAN were somewhat different
but I think this modified version is actually further from the FORTRAN. (Though
I must admit I know very little about FORTRAN 95).


-- 


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


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