Message ID | 201205131045.57270.ebotcazou@adacore.com |
---|---|
State | New |
Headers | show |
On Sun, May 13, 2012 at 10:45 AM, Eric Botcazou <ebotcazou@adacore.com> wrote: > Hi, > > this patch has been in our tree for a while and helps in Ada where you can do > block assignments to structures at will. I've attached a C testcase. The > unpatch compiler generates for it on PowerPC at -O2: > > foo: > lis 10,s@ha > li 8,27 > la 9,s@l(10) > stb 8,s@l(10) > li 10,108 > stb 10,1(9) > li 10,-79 > stb 10,2(9) > li 10,-58 > stb 10,3(9) > blr > .size foo, .-foo > .comm s,4,1 > > because it isn't able to put back together the individual initializations. > > The patched compiler generates instead: > > foo: > lis 9,.LANCHOR0@ha > lis 10,s@ha > lwz 9,.LANCHOR0@l(9) > stw 9,s@l(10) > blr > .size foo, .-foo > .comm s,4,1 > > .section .rodata > .set .LANCHOR0,. + 0 > .LC0: > .byte 27 > .byte 108 > .byte 177 > .byte 198 > > > Bootstrapped/regtested on i586-suse-linux, OK for mainline? Ok. Thanks, Richard. > > 2012-05-13 Eric Botcazou <ebotcazou@adacore.com> > > * gimplify.c (gimplify_init_constructor): Do a block move for very > small objects as well. > > > -- > Eric Botcazou
Index: gimplify.c =================================================================== --- gimplify.c (revision 187393) +++ gimplify.c (working copy) @@ -4033,9 +4033,13 @@ gimplify_init_constructor (tree *expr_p, else align = TYPE_ALIGN (type); + /* Do a block move either if the size is so small as to make + each individual move a sub-unit move on average, or if it + is so large as to make individual moves inefficient. */ if (size > 0 && num_nonzero_elements > 1 - && !can_move_by_pieces (size, align)) + && (size < num_nonzero_elements + || !can_move_by_pieces (size, align))) { if (notify_temp_creation) return GS_ERROR;