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

[Ada] More efficient code generated for object overlays


This change refines the use of the "volatile hammer" to implement the advice
given in RM 13.3(19) by disabling it for object overlays altogether. relying
instead on the ref-all aliasing property of reference types to achieve the
desired effect.

This will generate better code for object overlays, for example the following
function should now make no memory accesses at all on 64-bit platforms when
compiled at -O2 or above:

package Vec is

  type U64 is mod 2**64;

  function Prod (A, B : U64) return U64;

end Vec;
package body Vec is

  function Prod (A, B : U64) return U64 is
    type U16 is mod 2**16;
    type V16 is array (1..4) of U16;
    VA : V16;
    for VA'Address use A'Address;
    VB : V16;
    for VB'Address use B'Address;
    R : U64 := 0;
  begin
    for I in V16'Range loop
      R := R + U64(VA (I)) * U64(VB (I));
    end loop;
    return R;
  end;

end Vec;

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-11-12  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause): For a
	variable, if this is not an overlay, set on Treat_As_Volatile on it.
	* gcc-interface/decl.c (E_Variable): Do not force the type to volatile
	for address clauses. Tweak and adjust various RM references.

Attachment: difs
Description: Text document


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