From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9adfbb907494972e X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Ada to C/C++ translator needed Date: 1996/10/15 Message-ID: #1/1 X-Deja-AN: 189476061 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: houdini.camb.inmet.com references: <53fnp2$8bs$1@goanna.cs.rmit.edu.au> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-10-15T00:00:00+00:00 List-Id: Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote: : ... : Since this is comp.lang.ada, perhaps someone could explain clearly : whether an Ada compiler is allowed to perform this kind of optimisation : given : type Vector is array (Positive range <>) of Float; : procedure Vec_Add(A: out Vector; B, C: in Vector) is : begin : for I in A'Range loop A(I) := B(I) + C(I); end loop; : end Vec_Add; : I used to think that calls like : declare : X, Y: Vector(3) := (1..3 => 1.0); : begin : Vec_Add(X(2..3), X(1..2), Y(1..2)); : end; : were forbidden, because the result depended on whether 'in Vector' was : passed by copy or reference, but I probably got that wrong, and I am : even less sure of exactly what the rule is in Ada 95. A factor of 3 : speedup is worth having... The rules regarding aliasing between parameters are given in RM95-6.2(12). The generated code is allowed to result in the reading of an "old" value if there is aliasing between the parameters, and the code as written would imply a write of an object by one access path followed by a read of the object by some other access path. This implies that a loop may be unrolled, and then different iterations interleaved by moving certain of the reads earlier. : Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci. -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA