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

Re: [C++ RFC] Re: PR 10776

Hi Richard,

On Sun, 11 Jan 2004, Richard Henderson wrote:
> The following patch splits the initialization into compile-time and
> run-time pieces.  For this test, all but one store can be done at
> compile-time.

This patch reminded me of a discussion we'd had about a year or two
ago, but unfortunately I've yet to find it again in the gcc-patches

The suggestion was that we could optimize "auto const" arrays into
"static const" arrays, if we could determine that all of the values
in the array initializer were compile time constants.

i.e. we'd transform

void foo()
  const int a[3] = { 1, 2, 3 };

into the equivalent but far more efficient

void foo()
  static const int a[3] = { 1, 2, 3 };

At the time, we were investigating the mysterious reordering of
instructions that were writing to unchanging memory and the need
for scheduling barriers in the RTL we generated for initializing
const arrays.  Again I can't remember the actual PR number.

Your conclusion was that this shouldn't be done automatically in
the middle-end, but that we needed some way of identifying array
initializers where all elements were compile-time constants, and
make this function available to the front-ends so they could
perform the optimization themselves.

Would the functionality in your recent patch be suitable?


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