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]

[PATCH] Fix constant array ARRAY_REF[constant index] optimization (PR middle-end/28755)


Hi!

As shown by the attached testcase, the constant array ARRAY_REF
with constant index optimization is in some cases really big pessimization.
If expand_expr decides to put a CONSTRUCTOR into memory, then we just waste
rodata memory, while we in that case really should just use the original
array entry.
The following patches (attached 4.1 and 4.2 versions) check for this and
if it determines it is not a win, it falls back to using the actual
original array reference.  On 4.1 that works without a problem,
unfortunately in 4.2 it seems -fsection-anchors kills the garbage collection
of unused deferred constants.  I have worked around it in the patch, but
think it should be eventually fixed in the -fsection-anchors handling
instead and then this hack can be removed.

Ok for 4.1/4.2?

	Jakub

Attachment: gcc42-pr28755.patch
Description: Text document

Attachment: gcc41-pr28755.patch
Description: Text document


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