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

RFC: redundant stores in C++


In C++, when we have an automatic array with variable initializers:

void bar(char[4]);
void foo(char a, char b, char c, char d) {
  char x[4] = { a, b, c, d };
  bar(x);
}

the C++ FE generates 32-bit store(s) of 0 for the entire array, followed by stores
of the individual elements. In the case above, where the elements are not
32-bits, the optimizers do not figure out they can eliminate the redundant store(s)
of 0. The C FE does not generate that to begin with, and the C++ FE should
not either. This is not my native habitat, but I think this is the right general idea:

Attachment: diffs4.txt
Description: Text document


Testsuite passes with this but I can believe improvements are possible; comments?



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