[Bug tree-optimization/29543] Poor code generated for arrays with variable bounds
laurent at guerby dot net
gcc-bugzilla@gcc.gnu.org
Sun Oct 22 16:13:00 GMT 2006
------- Comment #9 from laurent at guerby dot net 2006-10-22 16:13 -------
Eric, build is "i686-pc-linux-gnu" I don't understand why you speak of
generalization :).
Anyway, I changed the code to match more likely use, that is by using a
subprogram:
procedure Compute (A, B : in Real_Matrix; C : out Real_Matrix) is
Sum : Float := 0.0;
begin
for I in A'range(1) loop
for J in A'range(2) loop
Sum := 0.0;
for R in A'range(2) loop
Sum := Sum + A(I,R)*B(R,J);
end loop;
C(I,J) := Sum;
end loop;
end loop;
end Compute;
...
Start := Ada.Calendar.Clock;
Compute (A.all, B.all, C.all);
Finish := Ada.Calendar.Clock;
On my x86_64 box at -O2 (-gnatp) Ada is still three times slower
cd ada ; ./tst_array 600
1.65129E+02 1.47839E+02
1.57425E+02 1.40635E+02
Time: 1.541291000
cd fortran ; ./tst_array 600
146.0253 145.0025 149.3322 150.8924
Time: 0.5400340
I don't know how to write the equivalent fortran code, but it's likely better
to concentrate on the subprogram version for optimization purpose.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29543
More information about the Gcc-bugs
mailing list